Skip to content

Commit

Permalink
Merge pull request #283 from instrumenta/issue-246
Browse files Browse the repository at this point in the history
fix: do not fail on empty lists
  • Loading branch information
carlossg committed Mar 30, 2021
2 parents 258f4a4 + 026c0d6 commit c63749c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions fixtures/list_empty_valid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
apiVersion: v1
kind: List
items: []
2 changes: 1 addition & 1 deletion kubeval/kubeval.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func ValidateWithCache(input []byte, schemaCache map[string]*gojsonschema.Schema
}{}

unmarshalErr := yaml.Unmarshal(input, &list)
isYamlList := unmarshalErr == nil && list.Items != nil && len(list.Items) > 0
isYamlList := unmarshalErr == nil && list.Items != nil

var bits [][]byte
if isYamlList {
Expand Down
1 change: 1 addition & 0 deletions kubeval/kubeval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func TestValidateValidInputs(t *testing.T) {
"full_domain_group.yaml",
"unconventional_keys.yaml",
"list_valid.yaml",
"list_empty_valid.yaml",
"same-object-different-namespace.yaml",
"same-object-different-namespace-default.yaml",
"duplicates-skipped-kinds.yaml",
Expand Down

0 comments on commit c63749c

Please sign in to comment.