Skip to content

Commit

Permalink
fix: use tmp for empty name check (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
Neal committed Jun 8, 2021
1 parent 0de9c0f commit bbd070b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 9 additions & 2 deletions yaml/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,14 @@ func (s *SecretSlice) UnmarshalYAML(unmarshal func(interface{}) error) error {
return err
}

tmp := SecretSlice{}

// iterate through each element in the secret slice
for _, secret := range *secretSlice {
// implicitly set `key` field if empty
if len(secret.Name) == 0 {
continue
}

if secret.Origin.Empty() && len(secret.Key) == 0 {
secret.Key = secret.Name
}
Expand Down Expand Up @@ -114,10 +119,12 @@ func (s *SecretSlice) UnmarshalYAML(unmarshal func(interface{}) error) error {
if !secret.Origin.Empty() && strings.EqualFold(secret.Origin.Pull, "false") {
secret.Origin.Pull = constants.PullNotPresent
}

tmp = append(tmp, secret)
}

// overwrite existing SecretSlice
*s = *secretSlice
*s = tmp

return nil
}
Expand Down
2 changes: 2 additions & 0 deletions yaml/testdata/secret.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
- source: foo
target: bar
- name: foo
key: bar
engine: native
Expand Down

0 comments on commit bbd070b

Please sign in to comment.