diff --git a/pkg/ingress/config/ingress_template.go b/pkg/ingress/config/ingress_template.go index f9fa422335..1c84644fbf 100644 --- a/pkg/ingress/config/ingress_template.go +++ b/pkg/ingress/config/ingress_template.go @@ -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 { @@ -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 diff --git a/pkg/ingress/config/ingress_template_test.go b/pkg/ingress/config/ingress_template_test.go index 300a19509e..98de51163b 100644 --- a/pkg/ingress/config/ingress_template_test.go +++ b/pkg/ingress/config/ingress_template_test.go @@ -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 {