Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance(secrets): uppercase secret target #387

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading