Skip to content

Commit

Permalink
enhance(secrets): uppercase secret target
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrupper committed Aug 13, 2024
1 parent d47730b commit ddf1fa4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
8 changes: 4 additions & 4 deletions yaml/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,11 @@ func TestYaml_Build_UnmarshalYAML(t *testing.T) {
Secrets: StepSecretSlice{
{
Source: "docker_username",
Target: "plugin_username",
Target: "PLUGIN_USERNAME",
},
{
Source: "docker_password",
Target: "plugin_password",
Target: "PLUGIN_PASSWORD",
},
},
},
Expand Down Expand Up @@ -308,11 +308,11 @@ func TestYaml_Build_UnmarshalYAML(t *testing.T) {
Secrets: StepSecretSlice{
{
Source: "docker_username",
Target: "docker_username",
Target: "DOCKER_USERNAME",
},
{
Source: "docker_password",
Target: "docker_password",
Target: "DOCKER_PASSWORD",
},
},
},
Expand Down
4 changes: 3 additions & 1 deletion yaml/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func (s *StepSecretSlice) UnmarshalYAML(unmarshal func(interface{}) error) error
// append the element to the step secret slice
*s = append(*s, &StepSecret{
Source: secret,
Target: secret,
Target: strings.ToUpper(secret),
})
}

Expand All @@ -257,6 +257,8 @@ func (s *StepSecretSlice) UnmarshalYAML(unmarshal func(interface{}) error) error
if len(secret.Source) == 0 || len(secret.Target) == 0 {
return fmt.Errorf("no secret source or target found")
}

secret.Target = strings.ToUpper(secret.Target)
}

// overwrite existing StepSecretSlice
Expand Down
16 changes: 8 additions & 8 deletions yaml/secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,11 @@ func TestYaml_SecretSlice_UnmarshalYAML(t *testing.T) {
Secrets: StepSecretSlice{
{
Source: "foo",
Target: "foo",
Target: "FOO",
},
{
Source: "foobar",
Target: "foobar",
Target: "FOOBAR",
},
},
},
Expand Down Expand Up @@ -296,11 +296,11 @@ func TestYaml_SecretSlice_UnmarshalYAML(t *testing.T) {
Secrets: StepSecretSlice{
{
Source: "foo",
Target: "foo",
Target: "FOO",
},
{
Source: "foobar",
Target: "foobar",
Target: "FOOBAR",
},
},
},
Expand Down Expand Up @@ -390,11 +390,11 @@ func TestYaml_StepSecretSlice_UnmarshalYAML(t *testing.T) {
want: &StepSecretSlice{
{
Source: "foo",
Target: "bar",
Target: "BAR",
},
{
Source: "hello",
Target: "world",
Target: "WORLD",
},
},
},
Expand All @@ -404,11 +404,11 @@ func TestYaml_StepSecretSlice_UnmarshalYAML(t *testing.T) {
want: &StepSecretSlice{
{
Source: "foo",
Target: "foo",
Target: "FOO",
},
{
Source: "hello",
Target: "hello",
Target: "HELLO",
},
},
},
Expand Down

0 comments on commit ddf1fa4

Please sign in to comment.