From b75a2cac1071bd7fe74a92e3a2e4d5b161edc164 Mon Sep 17 00:00:00 2001 From: Patrick Schratz Date: Thu, 26 Sep 2024 14:04:07 +0200 Subject: [PATCH] Update image filter error message (#4143) --- pipeline/frontend/yaml/compiler/compiler.go | 2 +- pipeline/frontend/yaml/compiler/compiler_test.go | 2 +- web/src/assets/locales/en.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pipeline/frontend/yaml/compiler/compiler.go b/pipeline/frontend/yaml/compiler/compiler.go index dd9654b1c..b9bdd09cc 100644 --- a/pipeline/frontend/yaml/compiler/compiler.go +++ b/pipeline/frontend/yaml/compiler/compiler.go @@ -46,7 +46,7 @@ type Secret struct { func (s *Secret) Available(event string, container *yaml_types.Container) error { onlyAllowSecretForPlugins := len(s.AllowedPlugins) > 0 if onlyAllowSecretForPlugins && !container.IsPlugin() { - return fmt.Errorf("secret %q only allowed to be used by plugins by step %q", s.Name, container.Name) + return fmt.Errorf("secret %q is only allowed to be used by plugins (a filter has been set on the secret). Note: Image filters do not work for normal steps", s.Name) } if onlyAllowSecretForPlugins && !utils.MatchImageDynamic(container.Image, s.AllowedPlugins...) { diff --git a/pipeline/frontend/yaml/compiler/compiler_test.go b/pipeline/frontend/yaml/compiler/compiler_test.go index 242229c61..82c68b9db 100644 --- a/pipeline/frontend/yaml/compiler/compiler_test.go +++ b/pipeline/frontend/yaml/compiler/compiler_test.go @@ -50,7 +50,7 @@ func TestSecretAvailable(t *testing.T) { assert.ErrorContains(t, secret.Available("push", &yaml_types.Container{ Image: "golang", Commands: yaml_base_types.StringOrSlice{"echo 'this is not a plugin'"}, - }), "only allowed to be used by plugins by step") + }), "is only allowed to be used by plugins (a filter has been set on the secret). Note: Image filters do not work for normal steps") assert.ErrorContains(t, secret.Available("push", &yaml_types.Container{ Image: "not-golang", Commands: yaml_base_types.StringOrSlice{}, diff --git a/web/src/assets/locales/en.json b/web/src/assets/locales/en.json index 8783b65e3..c55145f97 100644 --- a/web/src/assets/locales/en.json +++ b/web/src/assets/locales/en.json @@ -433,7 +433,7 @@ "saved": "Secret saved", "plugins": { "images": "Available only for the following plugins", - "desc": "List of plugins images where this secret is available, leave empty to allow for all plugins and general steps." + "desc": "List of plugin images where this secret is available. Leave empty to allow for all plugins and normal steps." }, "events": { "events": "Available at the following events",