123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416 |
- suite: container env test
- templates:
- - common.yaml
- tests:
- - it: should create the correct env
- set:
- some_value: value1
- some_other_value: 2
- image: &image
- repository: nginx
- tag: 1.19.0
- pullPolicy: IfNotPresent
- configmap:
- configmap-name:
- enabled: true
- data:
- key1: value1
- key2: value2
- secret:
- secret-name:
- enabled: true
- data:
- key1: value1
- key2: value2
- workload:
- workload-name:
- enabled: true
- primary: true
- type: Deployment
- podSpec:
- containers:
- container-name1:
- enabled: true
- primary: true
- imageSelector: image
- probes: &probes
- liveness:
- enabled: false
- readiness:
- enabled: false
- startup:
- enabled: false
- env:
- VAR1: "{{ .Values.some_value }}"
- VAR2: some_value
- VAR3:
- configMapKeyRef:
- name: configmap-name
- key: key1
- VAR4:
- secretKeyRef:
- name: secret-name
- key: key2
- VAR5:
- configMapKeyRef:
- expandObjectName: false
- name: configmap-name
- key: key3
- VAR6:
- secretKeyRef:
- expandObjectName: false
- name: secret-name
- key: key4
- VAR7:
- fieldRef:
- fieldPath: metadata.name
- VAR8: ""
- VAR9: false
- asserts:
- - documentIndex: &deploymentDoc 2
- isKind:
- of: Deployment
- - documentIndex: *deploymentDoc
- isAPIVersion:
- of: apps/v1
- - documentIndex: *deploymentDoc
- contains:
- path: spec.template.spec.containers[0].env
- content:
- name: VAR1
- value: value1
- - documentIndex: *deploymentDoc
- contains:
- path: spec.template.spec.containers[0].env
- content:
- name: VAR2
- value: some_value
- - documentIndex: *deploymentDoc
- contains:
- path: spec.template.spec.containers[0].env
- content:
- name: VAR3
- valueFrom:
- configMapKeyRef:
- key: key1
- name: release-name-common-test-configmap-name
- - documentIndex: *deploymentDoc
- contains:
- path: spec.template.spec.containers[0].env
- content:
- name: VAR4
- valueFrom:
- secretKeyRef:
- key: key2
- name: release-name-common-test-secret-name
- - documentIndex: *deploymentDoc
- contains:
- path: spec.template.spec.containers[0].env
- content:
- name: VAR5
- valueFrom:
- configMapKeyRef:
- key: key3
- name: configmap-name
- - documentIndex: *deploymentDoc
- contains:
- path: spec.template.spec.containers[0].env
- content:
- name: VAR6
- valueFrom:
- secretKeyRef:
- key: key4
- name: secret-name
- - documentIndex: *deploymentDoc
- contains:
- path: spec.template.spec.containers[0].env
- content:
- name: VAR7
- valueFrom:
- fieldRef:
- fieldPath: metadata.name
- - documentIndex: *deploymentDoc
- contains:
- path: spec.template.spec.containers[0].env
- content:
- name: VAR8
- value: ""
- - documentIndex: *deploymentDoc
- contains:
- path: spec.template.spec.containers[0].env
- content:
- name: VAR9
- value: "false"
- # Failures
- - it: it should fail invalid ref
- set:
- image: *image
- workload:
- workload-name:
- enabled: true
- primary: true
- type: Deployment
- podSpec:
- containers:
- container-name1:
- enabled: true
- primary: true
- imageSelector: image
- probes: *probes
- env:
- VAR:
- invalidKeyRef: {}
- asserts:
- - failedTemplate:
- errorMessage: Container - Expected <env> with a ref to have one of [configMapKeyRef, secretKeyRef, fieldRef], but got [invalidKeyRef]
- - it: it should fail with more than one ref
- set:
- image: *image
- workload:
- workload-name:
- enabled: true
- primary: true
- type: Deployment
- podSpec:
- containers:
- container-name1:
- enabled: true
- primary: true
- imageSelector: image
- probes: *probes
- env:
- VAR:
- configMapKeyRef: {}
- secretKeyRef: {}
- asserts:
- - failedTemplate:
- errorMessage: Container - Expected <env> with a ref to have one of [configMapKeyRef, secretKeyRef, fieldRef], but got [configMapKeyRef, secretKeyRef]
- - it: it should fail with empty name in configMapKeyRef
- set:
- image: *image
- workload:
- workload-name:
- enabled: true
- primary: true
- type: Deployment
- podSpec:
- containers:
- container-name1:
- enabled: true
- primary: true
- imageSelector: image
- probes: *probes
- env:
- VAR:
- configMapKeyRef:
- name: ""
- key: key
- asserts:
- - failedTemplate:
- errorMessage: Container - Expected non-empty <env.configMapKeyRef.name>
- - it: it should fail with empty key in configMapKeyRef
- set:
- image: *image
- workload:
- workload-name:
- enabled: true
- primary: true
- type: Deployment
- podSpec:
- containers:
- container-name1:
- enabled: true
- primary: true
- imageSelector: image
- probes: *probes
- env:
- VAR:
- configMapKeyRef:
- name: name
- key: ""
- asserts:
- - failedTemplate:
- errorMessage: Container - Expected non-empty <env.configMapKeyRef.key>
- - it: it should fail with empty name in secretKeyRef
- set:
- image: *image
- workload:
- workload-name:
- enabled: true
- primary: true
- type: Deployment
- podSpec:
- containers:
- container-name1:
- enabled: true
- primary: true
- imageSelector: image
- probes: *probes
- env:
- VAR:
- secretKeyRef:
- name: ""
- key: key
- asserts:
- - failedTemplate:
- errorMessage: Container - Expected non-empty <env.secretKeyRef.name>
- - it: it should fail with empty key in secretKeyRef
- set:
- image: *image
- workload:
- workload-name:
- enabled: true
- primary: true
- type: Deployment
- podSpec:
- containers:
- container-name1:
- enabled: true
- primary: true
- imageSelector: image
- probes: *probes
- env:
- VAR:
- secretKeyRef:
- name: name
- key: ""
- asserts:
- - failedTemplate:
- errorMessage: Container - Expected non-empty <env.secretKeyRef.key>
- - it: it should fail with referenced secret not defined
- set:
- image: *image
- workload:
- workload-name:
- enabled: true
- primary: true
- type: Deployment
- podSpec:
- containers:
- container-name1:
- enabled: true
- primary: true
- imageSelector: image
- probes: *probes
- env:
- VAR:
- secretKeyRef:
- name: secret-name
- key: somekey
- asserts:
- - failedTemplate:
- errorMessage: Container - Expected in <env> the referenced Secret [secret-name] to be defined
- - it: it should fail with referenced configmap not defined
- set:
- image: *image
- workload:
- workload-name:
- enabled: true
- primary: true
- type: Deployment
- podSpec:
- containers:
- container-name1:
- enabled: true
- primary: true
- imageSelector: image
- probes: *probes
- env:
- VAR:
- configMapKeyRef:
- name: configmap-name
- key: somekey
- asserts:
- - failedTemplate:
- errorMessage: Container - Expected in <env> the referenced Configmap [configmap-name] to be defined
- - it: it should fail with referenced key in configmap not defined
- set:
- image: *image
- configmap:
- configmap-name:
- enabled: true
- data:
- key1: value1
- key2: value2
- workload:
- workload-name:
- enabled: true
- primary: true
- type: Deployment
- podSpec:
- containers:
- container-name1:
- enabled: true
- primary: true
- imageSelector: image
- probes: *probes
- env:
- VAR:
- configMapKeyRef:
- name: configmap-name
- key: somekey
- asserts:
- - failedTemplate:
- errorMessage: Container - Expected in <env> the referenced key [somekey] in Configmap [configmap-name] to be defined
- - it: it should fail with referenced key in secret not defined
- set:
- image: *image
- secret:
- secret-name:
- enabled: true
- data:
- key1: value1
- key2: value2
- workload:
- workload-name:
- enabled: true
- primary: true
- type: Deployment
- podSpec:
- containers:
- container-name1:
- enabled: true
- primary: true
- imageSelector: image
- probes: *probes
- env:
- VAR:
- secretKeyRef:
- name: secret-name
- key: somekey
- asserts:
- - failedTemplate:
- errorMessage: Container - Expected in <env> the referenced key [somekey] in Secret [secret-name] to be defined
- - it: it should fail with empty fieldPath in fieldRef
- set:
- image: *image
- workload:
- workload-name:
- enabled: true
- primary: true
- type: Deployment
- podSpec:
- containers:
- container-name1:
- enabled: true
- primary: true
- imageSelector: image
- probes: *probes
- env:
- VAR:
- fieldRef:
- fieldPath: ""
- asserts:
- - failedTemplate:
- errorMessage: Container - Expected non-empty <env.fieldRef.fieldPath>
|