diff --git a/pkg/ingress/config/ingress_template.go b/pkg/ingress/config/ingress_template.go index f9fa4223..3833deb0 100644 --- a/pkg/ingress/config/ingress_template.go +++ b/pkg/ingress/config/ingress_template.go @@ -53,7 +53,7 @@ func (p *TemplateProcessor) ProcessConfig(cfg *config.Config) error { configStr := string(jsonBytes) // Find all value references in format: // ${type.name.key} or ${type.namespace/name.key} - valueRegex := regexp.MustCompile(`\$\{([^.}]+)\.(?:([^/]+)/)?([^.}]+)\.([^}]+)\}`) + valueRegex := regexp.MustCompile(`\$\{([^.}/]+)\.(?:([^/}]+)/)?([^.}/]+)\.([^}]+)\}`) matches := valueRegex.FindAllStringSubmatch(configStr, -1) // If there are no value references, return immediately if len(matches) == 0 { diff --git a/pkg/ingress/config/ingress_template_test.go b/pkg/ingress/config/ingress_template_test.go index 300a1950..f08d9ef7 100644 --- a/pkg/ingress/config/ingress_template_test.go +++ b/pkg/ingress/config/ingress_template_test.go @@ -114,6 +114,66 @@ func TestTemplateProcessor_ProcessConfig(t *testing.T) { }, expectError: false, }, + { + name: "config with default and non-default namespaces (default first)", + wasmPlugin: &extensions.WasmPlugin{ + PluginName: "test-plugin", + PluginConfig: makeStructValue(t, map[string]interface{}{ + "a1": map[string]interface{}{ + "type": "${secret.auth-secret.auth_config.type}", + "credentials": "${secret.auth-secret.auth_config.credentials}", + }, + "a2": map[string]interface{}{ + "timeout": "${secret.default/test-secret.plugin_conf.timeout}", + "max_retries": "${secret.default/test-secret.plugin_conf.max_retries}", + }, + }), + }, + expected: &extensions.WasmPlugin{ + PluginName: "test-plugin", + PluginConfig: makeStructValue(t, map[string]interface{}{ + "a1": map[string]interface{}{ + "type": "basic", + "credentials": "base64-encoded", + }, + "a2": map[string]interface{}{ + "timeout": "5000", + "max_retries": "3", + }, + }), + }, + expectError: false, + }, + { + name: "config with default and non-default namespaces (non-default first)", + wasmPlugin: &extensions.WasmPlugin{ + PluginName: "test-plugin", + PluginConfig: makeStructValue(t, map[string]interface{}{ + "a1": map[string]interface{}{ + "timeout": "${secret.default/test-secret.plugin_conf.timeout}", + "max_retries": "${secret.default/test-secret.plugin_conf.max_retries}", + }, + "a2": map[string]interface{}{ + "type": "${secret.auth-secret.auth_config.type}", + "credentials": "${secret.auth-secret.auth_config.credentials}", + }, + }), + }, + expected: &extensions.WasmPlugin{ + PluginName: "test-plugin", + PluginConfig: makeStructValue(t, map[string]interface{}{ + "a1": map[string]interface{}{ + "timeout": "5000", + "max_retries": "3", + }, + "a2": map[string]interface{}{ + "type": "basic", + "credentials": "base64-encoded", + }, + }), + }, + expectError: false, + }, { name: "non-existent secret", wasmPlugin: &extensions.WasmPlugin{