Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions pkg/ingress/config/ingress_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,13 @@ func (p *TemplateProcessor) ProcessConfig(cfg *config.Config) error {

// Get value using the provided getter function
value, err := p.getValue(valueType, namespace, name, key)
if err != nil {
return fmt.Errorf("failed to get %s value for %s/%s.%s: %v", valueType, namespace, name, key, err)
}
if err == nil {
// Replace placeholder with actual value
configStr = strings.Replace(configStr, match[0], value, 1)
} else {
// Ingore replacement if there is an error
IngressLog.Errorf("failed to get %s value for %s/%s.%s: %v", valueType, namespace, name, key, err)
}

// Add secret dependency if this is a secret reference
if valueType == "secret" && p.secretConfigMgr != nil {
Expand All @@ -94,8 +98,6 @@ func (p *TemplateProcessor) ProcessConfig(cfg *config.Config) error {
IngressLog.Errorf("failed to add secret dependency: %v", err)
}
}
// Replace placeholder with actual value
configStr = strings.Replace(configStr, match[0], value, 1)
}

// Create a new instance of the same type as cfg.Spec
Expand Down
26 changes: 25 additions & 1 deletion pkg/ingress/config/ingress_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,32 @@ func TestTemplateProcessor_ProcessConfig(t *testing.T) {
"api_key": "${secret.default/non-existent.api_key}",
}),
},
expectError: true,
expected: &extensions.WasmPlugin{
PluginName: "test-plugin",
PluginConfig: makeStructValue(t, map[string]interface{}{
"api_key": "${secret.default/non-existent.api_key}",
}),
},
expectError: false,
},
{
name: "config with multiple fields and non-existent secret",
wasmPlugin: &extensions.WasmPlugin{
PluginName: "test-plugin",
PluginConfig: makeStructValue(t, map[string]interface{}{
"api_key_non_existent": "${secret.default/non-existent.api_key}",
"api_key": "${secret.default/test-secret.api_key}",
}),
},
expected: &extensions.WasmPlugin{
PluginName: "test-plugin",
PluginConfig: makeStructValue(t, map[string]interface{}{
"api_key_non_existent": "${secret.default/non-existent.api_key}",
"api_key": "test-api-key",
}),
},
expectError: false,
},
}

for _, tt := range tests {
Expand Down