diff --git a/acceptance.bats b/acceptance.bats index 6f01335..ad39c42 100755 --- a/acceptance.bats +++ b/acceptance.bats @@ -64,6 +64,12 @@ [ "$output" = "Summary: 0 resource found in 1 file - Valid: 0, Invalid: 0, Errors: 0 Skipped: 0" ] } +@test "Pass when parsing a blank config file with a comment" { + run bin/kubeconform -summary fixtures/comment.yaml + [ "$status" -eq 0 ] + [ "$output" = "Summary: 0 resource found in 1 file - Valid: 0, Invalid: 0, Errors: 0 Skipped: 0" ] +} + @test "Fail when parsing a config with additional properties and strict set" { run bin/kubeconform -strict -k8sversion 1.16.0 fixtures/extra_property.yaml [ "$status" -eq 1 ] @@ -83,3 +89,19 @@ run bin/kubeconform -registry './fixtures/registry/{{ .ResourceKind }}{{ .KindSuffix }}.json' fixtures/test_crd.yaml [ "$status" -eq 0 ] } + +@test "Pass when parsing a config with additional properties" { + run bin/kubeconform -summary fixtures/extra_property.yaml + [ "$status" -eq 0 ] + [ "$output" = "Summary: 1 resource found in 1 file - Valid: 1, Invalid: 0, Errors: 0 Skipped: 0" ] +} + +@test "Pass when using a valid, preset --registry" { + run bin/kubeconform --registry kubernetesjsonschema.dev fixtures/valid.yaml + [ "$status" -eq 0 ] +} + +@test "Pass when using a valid HTTP --registry" { + run bin/kubeconform --registry 'https://kubernetesjsonschema.dev/{{ .NormalizedVersion }}-standalone{{ .StrictSuffix }}/{{ .ResourceKind }}{{ .KindSuffix }}.json' fixtures/valid.yaml + [ "$status" -eq 0 ] +} diff --git a/fixtures/extra_property.yaml b/fixtures/extra_property.yaml index c01fba1..f59db4f 100644 --- a/fixtures/extra_property.yaml +++ b/fixtures/extra_property.yaml @@ -1,10 +1,13 @@ --- -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: DaemonSet metadata: name: nginx-ds spec: replicas: 2 + selector: + matchLabels: + k8s-app: nginx-ds template: spec: containers: diff --git a/pkg/output/text.go b/pkg/output/text.go index 079b886..a2706b8 100644 --- a/pkg/output/text.go +++ b/pkg/output/text.go @@ -57,7 +57,7 @@ func (o *text) Write(filename, kind, name, version string, reserr error, skipped _, err = fmt.Fprintf(o.w, "%s - %s %s skipped\n", filename, name, kind) } o.nSkipped++ - case EMPTY: + case EMPTY: // sent to ensure we count the filename as parsed } return err