add test to validate a folder

This commit is contained in:
Yann Hamon 2020-06-06 18:46:08 +02:00
parent d9a6468d09
commit 9293920f2a
33 changed files with 206 additions and 0 deletions

View file

@ -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 ]

0
fixtures/blank.yaml Executable file → Normal file
View file

0
fixtures/comment.yaml Executable file → Normal file
View file

0
fixtures/duplicates-non-namespaced.yaml Executable file → Normal file
View file

0
fixtures/duplicates-skipped-kinds.yaml Executable file → Normal file
View file

0
fixtures/duplicates-with-namespace-default.yaml Executable file → Normal file
View file

0
fixtures/duplicates-with-namespace.yaml Executable file → Normal file
View file

0
fixtures/duplicates.yaml Executable file → Normal file
View file

0
fixtures/extra_property.yaml Executable file → Normal file
View file

View file

@ -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
---

View file

@ -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

0
fixtures/full_domain_group.yaml Executable file → Normal file
View file

0
fixtures/int_or_string.yaml Executable file → Normal file
View file

0
fixtures/invalid.yaml Executable file → Normal file
View file

0
fixtures/list_invalid.yaml Executable file → Normal file
View file

0
fixtures/list_valid.yaml Executable file → Normal file
View file

0
fixtures/missing_kind.yaml Executable file → Normal file
View file

0
fixtures/missing_kind_value.yaml Executable file → Normal file
View file

0
fixtures/multi_invalid.yaml Executable file → Normal file
View file

0
fixtures/multi_invalid_resources.yaml Executable file → Normal file
View file

0
fixtures/multi_valid.yaml Executable file → Normal file
View file

0
fixtures/multi_valid_source.yaml Executable file → Normal file
View file

0
fixtures/null_array.yaml Executable file → Normal file
View file

0
fixtures/null_string.yaml Executable file → Normal file
View file

0
fixtures/quantity.yaml Executable file → Normal file
View file

0
fixtures/same-kind-different-api.yaml Executable file → Normal file
View file

0
fixtures/same-object-different-namespace-default.yaml Executable file → Normal file
View file

0
fixtures/same-object-different-namespace.yaml Executable file → Normal file
View file

0
fixtures/test_crd.yaml Executable file → Normal file
View file

0
fixtures/unconventional_keys.yaml Executable file → Normal file
View file

0
fixtures/valid.json Executable file → Normal file
View file

0
fixtures/valid.yaml Executable file → Normal file
View file

0
fixtures/valid_version.yaml Executable file → Normal file
View file