Skip to content

Commit

Permalink
fix: add check for origin and name (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
Neal committed Jun 8, 2021
1 parent bbd070b commit 8396842
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion yaml/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (s *SecretSlice) UnmarshalYAML(unmarshal func(interface{}) error) error {

// iterate through each element in the secret slice
for _, secret := range *secretSlice {
if len(secret.Name) == 0 {
if secret.Origin.Empty() && len(secret.Name) == 0 {
continue
}

Expand Down
31 changes: 31 additions & 0 deletions yaml/secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,37 @@ func TestYaml_SecretSlice_UnmarshalYAML(t *testing.T) {
},
},
},
{
Name: "",
Key: "",
Engine: "",
Type: "",
Origin: Origin{
Environment: map[string]string{"FOO": "bar"},
Image: "target/vela-vault:latest",
Parameters: map[string]interface{}{
"addr": "vault.company.com",
},
Pull: "always",
Ruleset: Ruleset{
If: Rules{
Event: []string{"push"},
},
Operator: "and",
Matcher: "filepath",
},
Secrets: StepSecretSlice{
{
Source: "foo",
Target: "foo",
},
{
Source: "foobar",
Target: "foobar",
},
},
},
},
},
},
{
Expand Down
10 changes: 10 additions & 0 deletions yaml/testdata/secret.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,13 @@
ruleset:
event: [ push ]
secrets: [ foo, foobar ]
- origin:
environment:
FOO: bar
image: target/vela-vault:latest
pull: true
parameters:
addr: vault.company.com
ruleset:
event: [ push ]
secrets: [ foo, foobar ]

0 comments on commit 8396842

Please sign in to comment.