mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-02-21 13:46:18 +00:00
Fix uppercase from_secrets (#842)
Secret names where matched based on their lowercase value already just the conversion to lowercase for `from_secrets` was missing.
This commit is contained in:
parent
d49e2fdf17
commit
6ae7e2cc4f
2 changed files with 28 additions and 26 deletions
|
@ -69,7 +69,7 @@ func sanitizeParamValue(v interface{}, secrets map[string]Secret) (string, error
|
||||||
if fromSecret, ok := v.(map[string]interface{}); ok {
|
if fromSecret, ok := v.(map[string]interface{}); ok {
|
||||||
if secretNameI, ok := fromSecret["from_secret"]; ok {
|
if secretNameI, ok := fromSecret["from_secret"]; ok {
|
||||||
if secretName, ok := secretNameI.(string); ok {
|
if secretName, ok := secretNameI.(string); ok {
|
||||||
if secret, ok := secrets[secretName]; ok {
|
if secret, ok := secrets[strings.ToLower(secretName)]; ok {
|
||||||
return secret.Value, nil
|
return secret.Value, nil
|
||||||
}
|
}
|
||||||
return "", fmt.Errorf("no secret found for %q", secretName)
|
return "", fmt.Errorf("no secret found for %q", secretName)
|
||||||
|
|
|
@ -22,6 +22,7 @@ func TestParamsToEnv(t *testing.T) {
|
||||||
"tags": stringsToInterface("next", "latest"),
|
"tags": stringsToInterface("next", "latest"),
|
||||||
"tag": stringsToInterface("next"),
|
"tag": stringsToInterface("next"),
|
||||||
"my_secret": map[string]interface{}{"from_secret": "secret_token"},
|
"my_secret": map[string]interface{}{"from_secret": "secret_token"},
|
||||||
|
"UPPERCASE_SECRET": map[string]interface{}{"from_secret": "SECRET_TOKEN"},
|
||||||
}
|
}
|
||||||
want := map[string]string{
|
want := map[string]string{
|
||||||
"PLUGIN_STRING": "stringz",
|
"PLUGIN_STRING": "stringz",
|
||||||
|
@ -36,6 +37,7 @@ func TestParamsToEnv(t *testing.T) {
|
||||||
"PLUGIN_TAG": "next",
|
"PLUGIN_TAG": "next",
|
||||||
"PLUGIN_TAGS": "next,latest",
|
"PLUGIN_TAGS": "next,latest",
|
||||||
"PLUGIN_MY_SECRET": "FooBar",
|
"PLUGIN_MY_SECRET": "FooBar",
|
||||||
|
"PLUGIN_UPPERCASE_SECRET": "FooBar",
|
||||||
}
|
}
|
||||||
secrets := map[string]Secret{
|
secrets := map[string]Secret{
|
||||||
"secret_token": {Name: "secret_token", Value: "FooBar", Match: nil},
|
"secret_token": {Name: "secret_token", Value: "FooBar", Match: nil},
|
||||||
|
|
Loading…
Reference in a new issue