Skip to content

Commit c63749c

Browse files
authored
Merge pull request #283 from instrumenta/issue-246
fix: do not fail on empty lists
2 parents 258f4a4 + 026c0d6 commit c63749c

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

fixtures/list_empty_valid.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
apiVersion: v1
3+
kind: List
4+
items: []

kubeval/kubeval.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ func ValidateWithCache(input []byte, schemaCache map[string]*gojsonschema.Schema
284284
}{}
285285

286286
unmarshalErr := yaml.Unmarshal(input, &list)
287-
isYamlList := unmarshalErr == nil && list.Items != nil && len(list.Items) > 0
287+
isYamlList := unmarshalErr == nil && list.Items != nil
288288

289289
var bits [][]byte
290290
if isYamlList {

kubeval/kubeval_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func TestValidateValidInputs(t *testing.T) {
3636
"full_domain_group.yaml",
3737
"unconventional_keys.yaml",
3838
"list_valid.yaml",
39+
"list_empty_valid.yaml",
3940
"same-object-different-namespace.yaml",
4041
"same-object-different-namespace-default.yaml",
4142
"duplicates-skipped-kinds.yaml",

0 commit comments

Comments
 (0)