diff --git a/acceptance.bats b/acceptance.bats index 4d529e4..6c71957 100755 --- a/acceptance.bats +++ b/acceptance.bats @@ -6,6 +6,12 @@ [ "$output" = "Summary: 1 resource found in 1 file - Valid: 1, Invalid: 0, Errors: 0 Skipped: 0" ] } +@test "Pass when parsing a folder containing valid YAML files" { + run bin/kubeconform -summary fixtures/folder + [ "$status" -eq 0 ] + [ "$output" = "Summary: 7 resources found in 2 files - Valid: 7, Invalid: 0, Errors: 0 Skipped: 0" ] +} + @test "Pass when parsing a Kubernetes file with string and integer quantities" { run bin/kubeconform -verbose fixtures/quantity.yaml [ "$status" -eq 0 ] diff --git a/fixtures/blank.yaml b/fixtures/blank.yaml old mode 100755 new mode 100644 diff --git a/fixtures/comment.yaml b/fixtures/comment.yaml old mode 100755 new mode 100644 diff --git a/fixtures/duplicates-non-namespaced.yaml b/fixtures/duplicates-non-namespaced.yaml old mode 100755 new mode 100644 diff --git a/fixtures/duplicates-skipped-kinds.yaml b/fixtures/duplicates-skipped-kinds.yaml old mode 100755 new mode 100644 diff --git a/fixtures/duplicates-with-namespace-default.yaml b/fixtures/duplicates-with-namespace-default.yaml old mode 100755 new mode 100644 diff --git a/fixtures/duplicates-with-namespace.yaml b/fixtures/duplicates-with-namespace.yaml old mode 100755 new mode 100644 diff --git a/fixtures/duplicates.yaml b/fixtures/duplicates.yaml old mode 100755 new mode 100644 diff --git a/fixtures/extra_property.yaml b/fixtures/extra_property.yaml old mode 100755 new mode 100644 diff --git a/fixtures/folder/multi_valid.yaml b/fixtures/folder/multi_valid.yaml new file mode 100644 index 0000000..a336388 --- /dev/null +++ b/fixtures/folder/multi_valid.yaml @@ -0,0 +1,181 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: redis-master + labels: + app: redis + tier: backend + role: master +spec: + ports: + # the port that this service should serve on + - port: 6379 + targetPort: 6379 + selector: + app: redis + tier: backend + role: master +--- +apiVersion: v1 +kind: ReplicationController +metadata: + name: redis-master + # these labels can be applied automatically + # from the labels in the pod template if not set + labels: + app: redis + role: master + tier: backend +spec: + # this replicas value is default + # modify it according to your case + replicas: 1 + # selector can be applied automatically + # from the labels in the pod template if not set + # selector: + # app: guestbook + # role: master + # tier: backend + template: + metadata: + labels: + app: redis + role: master + tier: backend + spec: + containers: + - name: master + image: redis + resources: + requests: + cpu: 100m + memory: 100Mi + ports: + - containerPort: 6379 +--- +apiVersion: v1 +kind: Service +metadata: + name: redis-slave + labels: + app: redis + tier: backend + role: slave +spec: + ports: + # the port that this service should serve on + - port: 6379 + selector: + app: redis + tier: backend + role: slave +--- +apiVersion: v1 +kind: ReplicationController +metadata: + name: redis-slave + # these labels can be applied automatically + # from the labels in the pod template if not set + labels: + app: redis + role: slave + tier: backend +spec: + # this replicas value is default + # modify it according to your case + replicas: 2 + # selector can be applied automatically + # from the labels in the pod template if not set + # selector: + # app: guestbook + # role: slave + # tier: backend + template: + metadata: + labels: + app: redis + role: slave + tier: backend + spec: + containers: + - name: slave + image: gcr.io/google_samples/gb-redisslave:v1 + resources: + requests: + cpu: 100m + memory: 100Mi + env: + - name: GET_HOSTS_FROM + value: dns + # If your cluster config does not include a dns service, then to + # instead access an environment variable to find the master + # service's host, comment out the 'value: dns' line above, and + # uncomment the line below. + # value: env + ports: + - containerPort: 6379 +--- +apiVersion: v1 +kind: Service +metadata: + name: frontend + labels: + app: guestbook + tier: frontend +spec: + # if your cluster supports it, uncomment the following to automatically create + # an external load-balanced IP for the frontend service. + # type: LoadBalancer + ports: + # the port that this service should serve on + - port: 80 + selector: + app: guestbook + tier: frontend +--- +apiVersion: v1 +kind: ReplicationController +metadata: + name: frontend + # these labels can be applied automatically + # from the labels in the pod template if not set + labels: + app: guestbook + tier: frontend +spec: + # this replicas value is default + # modify it according to your case + replicas: 3 + # selector can be applied automatically + # from the labels in the pod template if not set + # selector: + # app: guestbook + # tier: frontend + template: + metadata: + labels: + app: guestbook + tier: frontend + spec: + containers: + - name: php-redis + image: gcr.io/google_samples/gb-frontend:v3 + resources: + requests: + cpu: 100m + memory: 100Mi + env: + - name: GET_HOSTS_FROM + value: dns + # If your cluster config does not include a dns service, then to + # instead access environment variables to find service host + # info, comment out the 'value: dns' line above, and uncomment the + # line below. + # value: env + ports: + - containerPort: 80 +--- +--- +# an empty resource with comments +--- diff --git a/fixtures/folder/valid.yaml b/fixtures/folder/valid.yaml new file mode 100644 index 0000000..07c350e --- /dev/null +++ b/fixtures/folder/valid.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: ReplicationController +metadata: + name: "bob" +spec: + replicas: 2 + selector: + app: nginx + template: + metadata: + name: nginx + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx + ports: + - containerPort: 80 diff --git a/fixtures/full_domain_group.yaml b/fixtures/full_domain_group.yaml old mode 100755 new mode 100644 diff --git a/fixtures/int_or_string.yaml b/fixtures/int_or_string.yaml old mode 100755 new mode 100644 diff --git a/fixtures/invalid.yaml b/fixtures/invalid.yaml old mode 100755 new mode 100644 diff --git a/fixtures/list_invalid.yaml b/fixtures/list_invalid.yaml old mode 100755 new mode 100644 diff --git a/fixtures/list_valid.yaml b/fixtures/list_valid.yaml old mode 100755 new mode 100644 diff --git a/fixtures/missing_kind.yaml b/fixtures/missing_kind.yaml old mode 100755 new mode 100644 diff --git a/fixtures/missing_kind_value.yaml b/fixtures/missing_kind_value.yaml old mode 100755 new mode 100644 diff --git a/fixtures/multi_invalid.yaml b/fixtures/multi_invalid.yaml old mode 100755 new mode 100644 diff --git a/fixtures/multi_invalid_resources.yaml b/fixtures/multi_invalid_resources.yaml old mode 100755 new mode 100644 diff --git a/fixtures/multi_valid.yaml b/fixtures/multi_valid.yaml old mode 100755 new mode 100644 diff --git a/fixtures/multi_valid_source.yaml b/fixtures/multi_valid_source.yaml old mode 100755 new mode 100644 diff --git a/fixtures/null_array.yaml b/fixtures/null_array.yaml old mode 100755 new mode 100644 diff --git a/fixtures/null_string.yaml b/fixtures/null_string.yaml old mode 100755 new mode 100644 diff --git a/fixtures/quantity.yaml b/fixtures/quantity.yaml old mode 100755 new mode 100644 diff --git a/fixtures/same-kind-different-api.yaml b/fixtures/same-kind-different-api.yaml old mode 100755 new mode 100644 diff --git a/fixtures/same-object-different-namespace-default.yaml b/fixtures/same-object-different-namespace-default.yaml old mode 100755 new mode 100644 diff --git a/fixtures/same-object-different-namespace.yaml b/fixtures/same-object-different-namespace.yaml old mode 100755 new mode 100644 diff --git a/fixtures/test_crd.yaml b/fixtures/test_crd.yaml old mode 100755 new mode 100644 diff --git a/fixtures/unconventional_keys.yaml b/fixtures/unconventional_keys.yaml old mode 100755 new mode 100644 diff --git a/fixtures/valid.json b/fixtures/valid.json old mode 100755 new mode 100644 diff --git a/fixtures/valid.yaml b/fixtures/valid.yaml old mode 100755 new mode 100644 diff --git a/fixtures/valid_version.yaml b/fixtures/valid_version.yaml old mode 100755 new mode 100644