feat(common): Release common library 3.7.1 (#383)

Co-authored-by: Aisling McGinn <me@aisling.dev>
This commit is contained in:
Bernd Schorgers 2025-02-11 13:23:27 +01:00 committed by GitHub
parent c94a28baa3
commit 433f6d132b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
146 changed files with 232 additions and 222 deletions

View file

@ -0,0 +1,109 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: container args override
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
notExists:
path: spec.template.spec.containers[0].args
- it: single string should pass
set:
controllers.main.containers.main.args: sleep infinity
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].args
value:
- sleep infinity
- it: multiline string should pass
set:
controllers.main.containers.main.args: |
echo hello
echo world
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].args
value:
- |-
echo hello
echo world
- it: single quoted string should pass
set:
controllers.main.containers.main.args: "sleep infinity"
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].args
value:
- sleep infinity
- it: list of strings should pass
set:
controllers.main.containers.main.args:
- sleep
- infinity
- "test"
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].args
value:
- sleep
- infinity
- test
- it: args from defaultContainerOptions should pass
set:
controllers.main.defaultContainerOptions:
args: value_of_args
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].args
value:
- value_of_args
- it: args from defaultContainerOptions with container override should pass
set:
controllers.main.defaultContainerOptions:
args: value_of_args
controllers.main.containers.main.args:
- value 1
- value 2
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].args
value:
- value 1
- value 2

View file

@ -0,0 +1,107 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: container command override
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
notExists:
path: spec.template.spec.containers[0].command
- it: single string should pass
set:
controllers.main.containers.main.command: /bin/sh
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].command
value:
- /bin/sh
- it: multiline string should pass
set:
controllers.main.containers.main.command: |
/bin/sh
-c
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].command
value:
- |-
/bin/sh
-c
- it: single quoted string should pass
set:
controllers.main.containers.main.command: "/bin/sh"
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].command
value:
- /bin/sh
- it: list of strings should pass
set:
controllers.main.containers.main.command:
- /bin/sh
- "-c"
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].command
value:
- /bin/sh
- -c
- it: command from defaultContainerOptions should pass
set:
controllers.main.defaultContainerOptions:
command: value_of_command
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].command
value:
- value_of_command
- it: command from defaultContainerOptions with container override should pass
set:
controllers.main.defaultContainerOptions:
command: value_of_command
controllers.main.containers.main.command:
- value 1
- value 2
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].command
value:
- value 1
- value 2

View file

@ -0,0 +1,273 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: container env values
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default should pass
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
notExists:
path: spec.template.spec.containers[0].env
- it: KeyValue string should pass
set:
controllers.main.containers.main.env:
string: value_of_env
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: string
value: value_of_env
- it: KeyValue float should pass
set:
controllers.main.containers.main.env:
string: 4.2
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: string
value: "4.2"
- it: KeyValue int should pass
set:
controllers.main.containers.main.env:
string: 1
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: string
value: "1"
- it: List should pass
set:
controllers.main.containers.main.env:
- name: STATIC_ENV_FROM_LIST
value: STATIC_ENV_VALUE_FROM_LIST
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: STATIC_ENV_FROM_LIST
value: STATIC_ENV_VALUE_FROM_LIST
- it: Explicit ValueFrom in list should pass
set:
controllers.main.containers.main.env:
- name: DYNAMIC_ENV_FROM_LIST
valueFrom:
fieldRef:
fieldPath: spec.nodeName
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: DYNAMIC_ENV_FROM_LIST
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- it: Implicit ValueFrom in list should pass
set:
controllers.main.containers.main.env:
- name: DYNAMIC_ENV_FROM_LIST
fieldRef:
fieldPath: spec.nodeName
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: DYNAMIC_ENV_FROM_LIST
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- it: Implicit ValueFrom should pass
set:
controllers.main.containers.main.env:
DYNAMIC_ENV:
fieldRef:
fieldPath: spec.nodeName
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: DYNAMIC_ENV
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- it: Templated value should pass
set:
controllers.main.containers.main.env:
DYNAMIC_ENV: "{{ .Release.Name }}-admin"
TEMPLATE_ENV:
valueFrom:
secretKeyRef:
name: "{{ .Release.Name }}-secret"
key: "{{ .Release.Name }}-key"
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: DYNAMIC_ENV
value: RELEASE-NAME-admin
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[1]
value:
name: TEMPLATE_ENV
valueFrom:
secretKeyRef:
key: "RELEASE-NAME-key"
name: "RELEASE-NAME-secret"
- it: Combined KeyValue with Explicit ValueFrom should pass
set:
controllers.main.containers.main.env:
STATIC_ENV: static
DYNAMIC_ENV:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: DYNAMIC_ENV
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[1]
value:
name: STATIC_ENV
value: static
- it: Env vars with dependsOn should pass
set:
controllers.main.containers.main.env:
STATIC_ENV: 1
DYNAMIC_ENV:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
dependsOn: STATIC_ENV
ORDERED_ENV:
value: true
dependsOn: STATIC_ENV
DEPENDENT_ENV:
value: moo_two
dependsOn:
- DYNAMIC_ENV
- ORDERED_ENV
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: STATIC_ENV
value: "1"
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[1]
value:
name: DYNAMIC_ENV
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[2]
value:
name: ORDERED_ENV
value: "true"
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[3]
value:
name: DEPENDENT_ENV
value: moo_two
- it: env from defaultContainerOptions should pass
set:
controllers.main.defaultContainerOptions:
env:
string: value_of_env
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: string
value: value_of_env
- it: env from defaultContainerOptions with container override should pass
set:
controllers.main.defaultContainerOptions:
env:
string: value_of_env
controllers.main.containers.main.env:
someThingElse: value_of_env
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: someThingElse
value: value_of_env

View file

@ -0,0 +1,195 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: container envFrom values
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default should pass
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
notExists:
path: spec.template.spec.containers[0].envFrom
- it: explicit envFrom should pass
set:
controllers.main.containers.main.envFrom:
- secretRef:
name: myCustomSecret
prefix: test
- configMapRef:
name: myCustomConfig
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].envFrom[0]
value:
secretRef:
name: myCustomSecret
prefix: test
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].envFrom[1]
value:
configMapRef:
name: myCustomConfig
- it: envFrom from defaultContainerOptions should pass
set:
controllers.main.defaultContainerOptions:
envFrom:
- secretRef:
name: myCustomSecret
prefix: test
- configMapRef:
name: myCustomConfig
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].envFrom[0]
value:
secretRef:
name: myCustomSecret
prefix: test
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].envFrom[1]
value:
configMapRef:
name: myCustomConfig
- it: envFrom from defaultContainerOptions with container override should pass
set:
controllers.main.defaultContainerOptions:
envFrom:
- secretRef:
name: myCustomSecret
prefix: test
- configMapRef:
name: myCustomConfig
controllers.main.containers.main.envFrom:
- secretRef:
name: myCustomSecretOverride
prefix: test
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].envFrom[0]
value:
secretRef:
name: myCustomSecretOverride
prefix: test
- documentIndex: *DeploymentDoc
notExists:
path: spec.template.spec.containers[0].envFrom[1]
- it: envFrom configmap identifier reference should pass
set:
controllers.main.containers.main.envFrom:
- configMap: config
prefix: test
- configMapRef:
identifier: config
configMaps:
config:
data:
test: test
asserts:
- documentIndex: &DeploymentDoc 1
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].envFrom[0]
value:
configMapRef:
name: RELEASE-NAME-config
prefix: test
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].envFrom[1]
value:
configMapRef:
name: RELEASE-NAME-config
- it: envFrom Secret identifier reference should pass
set:
controllers.main.containers.main.envFrom:
- secret: secret
prefix: test
- secretRef:
identifier: secret
prefix: test
secrets:
secret:
stringData:
test: test
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].envFrom[0]
value:
secretRef:
name: RELEASE-NAME-secret
prefix: test
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].envFrom[1]
value:
secretRef:
name: RELEASE-NAME-secret
prefix: test
- it: envFrom with templated name reference should pass
set:
controllers.main.containers.main.envFrom:
- configMap: "{{ .Release.Name }}-config"
- configMapRef:
name: "{{ .Release.Name }}-config2"
- secret: "{{ .Release.Name }}-secret"
- secretRef:
name: "{{ .Release.Name }}-secret2"
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].envFrom[0]
value:
configMapRef:
name: RELEASE-NAME-config
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].envFrom[1]
value:
configMapRef:
name: RELEASE-NAME-config2
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].envFrom[2]
value:
secretRef:
name: RELEASE-NAME-secret
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].envFrom[3]
value:
secretRef:
name: RELEASE-NAME-secret2

View file

@ -0,0 +1,88 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: container image tag
templates:
- common.yaml
tests:
- it: string tag should pass
values:
- ../_values/controllers_main_default_container.yaml
set:
controllers.main.containers.main.image:
repository: ghcr.io/mendhak/http-https-echo
tag: latest
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].image
value: ghcr.io/mendhak/http-https-echo:latest
- it: integer tag should pass
values:
- ../_values/controllers_main_default_container.yaml
set:
controllers.main.containers.main.image:
repository: ghcr.io/mendhak/http-https-echo
tag: 1.23
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].image
value: ghcr.io/mendhak/http-https-echo:1.23
- it: template tag should pass
values:
- ../_values/controllers_main_default_container.yaml
set:
controllers.main.containers.main.image:
repository: ghcr.io/mendhak/http-https-echo
tag: "{{.Chart.Version}}"
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].image
value: ghcr.io/mendhak/http-https-echo:1.0.0
- it: tag from defaultContainerOptions should pass
set:
controllers.main:
defaultContainerOptions:
image:
repository: ghcr.io/mendhak/http-https-echo
tag: 32
containers:
main: {} # needed to have at least a container enabled
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].image
value: ghcr.io/mendhak/http-https-echo:32
- it: tag from defaultContainerOptions with container override should pass
set:
controllers.main.defaultContainerOptions.image:
repository: ghcr.io/mendhak/http-https-echo
tag: 32
controllers.main.containers.main.image:
repository: ghcr.io/mendhak/http-https-echo-override
tag: 33
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].image
value: ghcr.io/mendhak/http-https-echo-override:33

View file

@ -0,0 +1,142 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: container resources
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
notExists:
path: spec.template.spec.containers[0].resources
- it: defaultContainerOption should pass
set:
controllers:
main:
defaultContainerOptions:
resources:
requests:
memory: 1Gi
initContainers:
test:
image:
repository: ghcr.io/mendhak/http-https-echo
tag: 31
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].resources
value:
requests:
memory: 1Gi
- documentIndex: 0
equal:
path: spec.template.spec.initContainers[0].resources
value:
requests:
memory: 1Gi
- it: defaultContainerOption with container override should pass
set:
controllers:
main:
defaultContainerOptions:
resources:
requests:
memory: 1Gi
containers:
main:
resources:
requests:
memory: 2Gi
initContainers:
test:
image:
repository: ghcr.io/mendhak/http-https-echo
tag: 31
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].resources
value:
requests:
memory: 2Gi
- documentIndex: 0
equal:
path: spec.template.spec.initContainers[0].resources
value:
requests:
memory: 1Gi
- it: defaultContainerOption with initContainer override should pass
set:
controllers:
main:
defaultContainerOptions:
resources:
requests:
memory: 1Gi
initContainers:
test:
image:
repository: ghcr.io/mendhak/http-https-echo
tag: 31
resources:
requests:
memory: 2Gi
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].resources
value:
requests:
memory: 1Gi
- documentIndex: 0
equal:
path: spec.template.spec.initContainers[0].resources
value:
requests:
memory: 2Gi
- it: defaultContainerOption disabled for initContainer should pass
set:
controllers:
main:
applyDefaultContainerOptionsToInitContainers: false
defaultContainerOptions:
resources:
requests:
memory: 1Gi
initContainers:
test:
image:
repository: ghcr.io/mendhak/http-https-echo
tag: 31
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].resources
value:
requests:
memory: 1Gi
- documentIndex: 0
notExists:
path: spec.template.spec.initContainers[0].resources

View file

@ -0,0 +1,31 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: container restartPolicy
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
notExists:
path: spec.template.spec.containers[0].restartPolicy
- it: custom restartPolicy should pass
set:
controllers.main.containers:
main:
restartPolicy: Always
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].restartPolicy
value: Always

View file

@ -0,0 +1,59 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: container securityContext
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
notExists:
path: spec.template.spec.containers[0].securityContext
- it: defaultContainerOption should pass
set:
controllers:
main:
defaultContainerOptions:
securityContext:
runAsUser: 1000
runAsGroup: 1000
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].securityContext
value:
runAsUser: 1000
runAsGroup: 1000
- it: defaultContainerOption with container override should pass
set:
controllers:
main:
defaultContainerOptions:
securityContext:
runAsUser: 1000
runAsGroup: 1000
containers:
main:
securityContext:
runAsUser: 568
runAsGroup: 568
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].securityContext
value:
runAsUser: 568
runAsGroup: 568

View file

@ -0,0 +1,30 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: container stdin
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
notExists:
path: spec.template.spec.containers[0].stdin
- it: custom stdin should pass
set:
controllers.main.containers:
main:
stdin: true
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].stdin
value: true

View file

@ -0,0 +1,30 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: container tty
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
notExists:
path: spec.template.spec.containers[0].tty
- it: custom tty should pass
set:
controllers.main.containers:
main:
tty: true
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].tty
value: true

View file

@ -0,0 +1,54 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: container name
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: with explicit name should pass
set:
controllers.main.containers:
main:
nameOverride: template-test
image:
repository: ghcr.io/mendhak/http-https-echo
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].name
value: template-test
- it: with implicit name should pass
set:
controllers.main.containers:
main:
image:
repository: ghcr.io/mendhak/http-https-echo
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].name
value: main
- it: with templated name should pass
set:
controllers.main.containers:
main:
nameOverride: "{{ .Release.Name }}-container"
image:
repository: ghcr.io/mendhak/http-https-echo
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].name
value: RELEASE-NAME-container

View file

@ -0,0 +1,39 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: container ports
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
notExists:
path: spec.template.spec.containers[0].ports
- it: custom port should pass
set:
controllers:
main:
containers:
main:
ports:
- containerPort: 8080
name: http
protocol: TCP
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].ports[0]
value:
containerPort: 8080
name: http
protocol: TCP

View file

@ -0,0 +1,437 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: container probes
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
- ../_values/service_main_default.yaml
set:
controllers.main.containers.main.probes.liveness.enabled: true
controllers.main.containers.main.probes.readiness.enabled: true
controllers.main.containers.main.probes.startup.enabled: true
tests:
- it: default probes
documentSelector: &DeploymentSelector
path: $[?(@.kind == "Deployment")].metadata.name
value: RELEASE-NAME
asserts:
- equal:
path: spec.template.spec.containers[0].livenessProbe
value:
failureThreshold: 3
initialDelaySeconds: 0
periodSeconds: 10
tcpSocket:
port: 8081
timeoutSeconds: 1
- equal:
path: spec.template.spec.containers[0].readinessProbe
value:
failureThreshold: 3
initialDelaySeconds: 0
periodSeconds: 10
tcpSocket:
port: 8081
timeoutSeconds: 1
- equal:
path: spec.template.spec.containers[0].startupProbe
value:
failureThreshold: 3
initialDelaySeconds: 0
periodSeconds: 10
tcpSocket:
port: 8081
timeoutSeconds: 1
- it: custom primary port gets picked up by probes
set:
service.main.ports.test:
enabled: true
primary: true
port: 8080
documentSelector: *DeploymentSelector
asserts:
- documentIndex: 0
isKind:
of: Deployment
- equal:
path: spec.template.spec.containers[0].livenessProbe
value:
failureThreshold: 3
initialDelaySeconds: 0
periodSeconds: 10
tcpSocket:
port: 8080
timeoutSeconds: 1
- equal:
path: spec.template.spec.containers[0].readinessProbe
value:
failureThreshold: 3
initialDelaySeconds: 0
periodSeconds: 10
tcpSocket:
port: 8080
timeoutSeconds: 1
- equal:
path: spec.template.spec.containers[0].startupProbe
value:
failureThreshold: 3
initialDelaySeconds: 0
periodSeconds: 10
tcpSocket:
port: 8080
timeoutSeconds: 1
- it: probes with string Service port
set:
service.main.ports.http.port: "80"
documentSelector: *DeploymentSelector
asserts:
- equal:
path: spec.template.spec.containers[0].livenessProbe
value:
failureThreshold: 3
initialDelaySeconds: 0
periodSeconds: 10
tcpSocket:
port: 80
timeoutSeconds: 1
- equal:
path: spec.template.spec.containers[0].readinessProbe
value:
failureThreshold: 3
initialDelaySeconds: 0
periodSeconds: 10
tcpSocket:
port: 80
timeoutSeconds: 1
- equal:
path: spec.template.spec.containers[0].startupProbe
value:
failureThreshold: 3
initialDelaySeconds: 0
periodSeconds: 10
tcpSocket:
port: 80
timeoutSeconds: 1
- it: multiple services are handled correctly
set:
controllers:
other:
containers:
main:
image:
repository: ghcr.io/mendhak/http-https-echo
tag: 31
pullPolicy: IfNotPresent
probes:
liveness:
enabled: true
readiness:
enabled: true
startup:
enabled: true
service:
other:
controller: other
ports:
http:
enabled: true
port: 8080
asserts:
- documentSelector:
path: $[?(@.kind == "Deployment")].metadata.name
value: RELEASE-NAME-main
equal:
path: spec.template.spec.containers[0].livenessProbe.tcpSocket.port
value: 8081
- documentSelector:
path: $[?(@.kind == "Deployment")].metadata.name
value: RELEASE-NAME-main
equal:
path: spec.template.spec.containers[0].readinessProbe.tcpSocket.port
value: 8081
- documentSelector:
path: $[?(@.kind == "Deployment")].metadata.name
value: RELEASE-NAME-main
equal:
path: spec.template.spec.containers[0].startupProbe.tcpSocket.port
value: 8081
- documentSelector:
path: $[?(@.kind == "Deployment")].metadata.name
value: RELEASE-NAME-other
equal:
path: spec.template.spec.containers[0].livenessProbe.tcpSocket.port
value: 8080
- documentSelector:
path: $[?(@.kind == "Deployment")].metadata.name
value: RELEASE-NAME-other
equal:
path: spec.template.spec.containers[0].readinessProbe.tcpSocket.port
value: 8080
- documentSelector:
path: $[?(@.kind == "Deployment")].metadata.name
value: RELEASE-NAME-other
equal:
path: spec.template.spec.containers[0].startupProbe.tcpSocket.port
value: 8080
- it: no probes are defined when services are disabled
set:
service:
main:
enabled: false
controller: main
documentSelector: *DeploymentSelector
asserts:
- notExists:
path: spec.template.spec.containers[0].livenessProbe
- notExists:
path: spec.template.spec.containers[0].readinessProbe
- notExists:
path: spec.template.spec.containers[0].startupProbe
- it: AUTO type probe can be configured
set:
service.main.ports.http.protocol: HTTP
controllers.main.containers.main.probes:
liveness:
enabled: true
type: AUTO
path: /api/version
documentSelector: *DeploymentSelector
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].livenessProbe
value:
httpGet:
path: /api/version
port: 8081
scheme: HTTP
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
- it: HTTP type probe can be configured
set:
controllers.main.containers.main.probes:
liveness:
enabled: true
type: HTTP
path: /api/version
documentSelector: *DeploymentSelector
asserts:
- equal:
path: spec.template.spec.containers[0].livenessProbe
value:
httpGet:
path: /api/version
port: 8081
scheme: HTTP
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
- it: HTTPS type probe can be configured
set:
controllers.main.containers.main.probes:
liveness:
enabled: true
type: HTTPS
path: /api/version
documentSelector: *DeploymentSelector
asserts:
- equal:
path: spec.template.spec.containers[0].livenessProbe
value:
httpGet:
path: /api/version
port: 8081
scheme: HTTPS
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
- it: GRPC type probe can be configured without service
set:
controllers.main.containers.main.probes:
liveness:
enabled: true
type: GRPC
documentSelector: *DeploymentSelector
asserts:
- equal:
path: spec.template.spec.containers[0].livenessProbe
value:
grpc:
port: 8081
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
- it: GRPC type probe can be configured with service
set:
controllers.main.containers.main.probes:
liveness:
enabled: true
type: GRPC
service: test
documentSelector: *DeploymentSelector
asserts:
- equal:
path: spec.template.spec.containers[0].livenessProbe
value:
grpc:
port: 8081
service: test
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
- it: custom liveness probe can be configured
set:
controllers.main.containers.main.probes:
liveness:
enabled: true
custom: true
spec:
httpGet:
path: /api/version
port: 8081
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
documentSelector: *DeploymentSelector
asserts:
- equal:
path: spec.template.spec.containers[0].livenessProbe
value:
httpGet:
path: /api/version
port: 8081
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
- it: custom readiness probe can be configured
set:
controllers.main.containers.main.probes:
readiness:
enabled: true
custom: true
spec:
httpGet:
path: /api/version
port: 8081
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
documentSelector: *DeploymentSelector
asserts:
- equal:
path: spec.template.spec.containers[0].readinessProbe
value:
httpGet:
path: /api/version
port: 8081
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
- it: custom startup probe can be configured
set:
controllers.main.containers.main.probes:
startup:
enabled: true
custom: true
spec:
httpGet:
path: /api/version
port: 8081
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
documentSelector: *DeploymentSelector
asserts:
- equal:
path: spec.template.spec.containers[0].startupProbe
value:
httpGet:
path: /api/version
port: 8081
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
- it: User-defined liveness probe port can be configured
set:
controllers.main.containers.main.probes:
liveness:
enabled: true
port: http
documentSelector: *DeploymentSelector
asserts:
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].livenessProbe
value:
failureThreshold: 3
initialDelaySeconds: 0
periodSeconds: 10
tcpSocket:
port: http
timeoutSeconds: 1
- it: User-defined readiness probe port can be configured
set:
controllers.main.containers.main.probes:
readiness:
enabled: true
port: http
documentSelector: *DeploymentSelector
asserts:
- equal:
path: spec.template.spec.containers[0].readinessProbe
value:
failureThreshold: 3
initialDelaySeconds: 0
periodSeconds: 10
tcpSocket:
port: http
timeoutSeconds: 1
- it: User-defined startup probe port can be configured
set:
controllers.main.containers.main.probes:
startup:
enabled: true
port: http
documentSelector: *DeploymentSelector
asserts:
- equal:
path: spec.template.spec.containers[0].startupProbe
value:
failureThreshold: 3
initialDelaySeconds: 0
periodSeconds: 10
tcpSocket:
port: http
timeoutSeconds: 1

View file

@ -0,0 +1,33 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: Container validations
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: image repository is required
set:
controllers:
main:
containers:
test:
image:
repository: ""
tag: "test"
asserts:
- failedTemplate:
errorMessage: "No image repository specified for container. (controller main, container test)"
- it: image tag is required
set:
controllers:
main:
containers:
test:
image:
repository: test
tag: ""
asserts:
- failedTemplate:
errorMessage: "No image tag specified for container. (controller main, container test)"

View file

@ -0,0 +1,291 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: container volumeMounts
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: no persistence should pass
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
notExists:
path: spec.template.spec.containers[0].volumeMounts
- it: default should pass
set:
persistence:
config:
accessMode: ReadWriteOnce
size: 1Gi
asserts:
- documentIndex: &DeploymentDoc 1
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: config
mountPath: /config
- it: advanced mount config should pass
set:
controllers:
main:
containers:
second-container:
image:
repository: ghcr.io/mendhak/http-https-echo
tag: 31
second:
containers:
first-container:
image:
repository: ghcr.io/mendhak/http-https-echo
tag: 31
persistence:
data:
type: configMap
name: myConfigMap
globalMounts:
- path: /globalTest
advancedMounts:
main:
main:
- path: /data/config.yaml
readOnly: false
mountPropagation: HostToContainer
subPath: config.yaml
second-container:
- path: /appdata/config
readOnly: true
second:
first-container:
- path: /second-pod/config.yaml
readOnly: false
subPath: config.yaml
asserts:
- documentIndex: &FirstDeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *FirstDeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts
value:
- mountPath: /globalTest
name: data
- mountPath: /data/config.yaml
name: data
subPath: config.yaml
mountPropagation: HostToContainer
- documentIndex: *FirstDeploymentDoc
equal:
path: spec.template.spec.containers[1].volumeMounts
value:
- mountPath: /globalTest
name: data
- mountPath: /appdata/config
name: data
readOnly: true
- documentIndex: &SecondDeploymentDoc 1
isKind:
of: Deployment
- documentIndex: *SecondDeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts
value:
- mountPath: /globalTest
name: data
- mountPath: /second-pod/config.yaml
name: data
subPath: config.yaml
- it: emptyDir should pass
set:
persistence:
cache:
type: emptyDir
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: cache
mountPath: /cache
- it: custom mountPath should pass
set:
persistence:
config:
accessMode: ReadWriteMany
size: 1G
globalMounts:
- path: /custom
asserts:
- documentIndex: &DeploymentDoc 1
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: config
mountPath: /custom
- it: mount with subPath should pass
set:
persistence:
config:
existingClaim: myClaim
globalMounts:
- path: /config
subPath: "mySubPath"
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: config
mountPath: /config
subPath: mySubPath
- it: hostPath with custom mountPath should pass
set:
persistence:
config:
type: hostPath
hostPath: /tmp
globalMounts:
- path: /data
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: config
mountPath: /data
- it: hostPath mount with subPath should pass
set:
persistence:
config:
type: hostPath
hostPath: /dev
globalMounts:
- subPath: mySubPath
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: config
mountPath: /dev
subPath: mySubPath
- it: volumeClaimTemplates with default mounts should pass
set:
controllers.main:
type: statefulset
statefulset:
volumeClaimTemplates:
- name: "storage"
accessMode: "ReadWriteOnce"
size: "10Gi"
storageClass: "storage"
asserts:
- documentIndex: &StatefulSetDoc 0
isKind:
of: StatefulSet
- documentIndex: *StatefulSetDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: storage
mountPath: /storage
- it: volumeClaimTemplates with globalMounts should pass
set:
controllers.main:
type: statefulset
statefulset:
volumeClaimTemplates:
- name: "storage"
accessMode: "ReadWriteOnce"
size: "10Gi"
storageClass: "storage"
globalMounts:
- path: /tmp/storage
- path: /tmp/secondMountPoint
asserts:
- documentIndex: &StatefulSetDoc 0
isKind:
of: StatefulSet
- documentIndex: *StatefulSetDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: storage
mountPath: /tmp/storage
- documentIndex: *StatefulSetDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[1]
value:
name: storage
mountPath: /tmp/secondMountPoint
- it: volumeClaimTemplates with advancedMounts should pass
set:
controllers.main:
type: statefulset
statefulset:
volumeClaimTemplates:
- name: "storage"
accessMode: "ReadWriteOnce"
size: "10Gi"
storageClass: "storage"
advancedMounts:
second-container:
- path: /tmp/storage
- path: /tmp/secondMountPoint
containers:
second-container:
image:
repository: ghcr.io/mendhak/http-https-echo
tag: 31
asserts:
- documentIndex: &StatefulSetDoc 0
isKind:
of: StatefulSet
- documentIndex: *StatefulSetDoc
notExists:
path: spec.template.spec.containers[0].volumeMounts
- documentIndex: *StatefulSetDoc
equal:
path: spec.template.spec.containers[1].volumeMounts[0]
value:
name: storage
mountPath: /tmp/storage
- documentIndex: *StatefulSetDoc
equal:
path: spec.template.spec.containers[1].volumeMounts[1]
value:
name: storage
mountPath: /tmp/secondMountPoint

View file

@ -0,0 +1,40 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: container workingDir override
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
notExists:
path: spec.template.spec.containers[0].workingDir
- it: string should pass
set:
controllers.main.containers.main.workingDir: /work
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].workingDir
value: /work
- it: quoted string should pass
set:
controllers.main.containers.main.workingDir: "/work"
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].workingDir
value: /work