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,111 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod with multiple containers
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: with explicit name should pass
set:
controllers.main.containers:
additional1:
nameOverride: template-test
dependsOn: main
image:
repository: test
tag: test
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[1].name
value: template-test
- it: with implicit name should pass
set:
controllers.main.containers:
additional1:
dependsOn: main
image:
repository: test
tag: test
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[1].name
value: additional1
- it: with templated name should pass
set:
controllers.main.containers:
additional1:
nameOverride: "{{ .Release.Name }}-container"
dependsOn: main
image:
repository: test
tag: test
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[1].name
value: RELEASE-NAME-container
- it: with custom env vars dict should pass
set:
controllers.main.containers:
main:
env:
main_env: value
additional1:
dependsOn: main
image:
repository: test
tag: test
env:
int: 1
float: 1.5
string: value_of_env
template: "{{ .Release.Name }}-admin"
asserts:
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: main_env
value: "value"
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[1].env[0]
value:
name: float
value: "1.5"
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[1].env[1]
value:
name: int
value: "1"
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[1].env[2]
value:
name: string
value: value_of_env
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[1].env[3]
value:
name: template
value: RELEASE-NAME-admin

View file

@ -0,0 +1,86 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod sidecar containers
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: with default order
set:
controllers.main.containers:
main:
image:
repository: test
tag: test
additional1:
image:
repository: test
tag: test
additional2:
image:
repository: test
tag: test
asserts:
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
lengthEqual:
path: spec.template.spec.containers
count: 3
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[0].name
value: additional1
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[1].name
value: additional2
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[2].name
value: main
- it: with dependsOn
set:
controllers.main.containers:
additional1:
dependsOn: additional3
image:
repository: test
tag: test
additional2:
dependsOn: additional3
image:
repository: test
tag: test
additional3:
dependsOn: main
image:
repository: test
tag: test
asserts:
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
lengthEqual:
path: spec.template.spec.containers
count: 4
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[0].name
value: main
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[1].name
value: additional3
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[2].name
value: additional1
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[3].name
value: additional2

View file

@ -0,0 +1,114 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod affinity
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: affinity is not present by default
documentSelector: &DeploymentSelector
path: $[?(@.kind == "Deployment")].metadata.name
value: RELEASE-NAME
asserts:
- notExists:
path: spec.template.spec.affinity
- it: affinity can be set with defaultPodOption
set:
defaultPodOptions:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: topology.kubernetes.io/zone
operator: In
values:
- antarctica-east1
- antarctica-west1
documentSelector: *DeploymentSelector
asserts:
- equal:
path: spec.template.spec.affinity
value:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: topology.kubernetes.io/zone
operator: In
values:
- antarctica-east1
- antarctica-west1
- it: affinity can be set with defaultPodOption and overridden on pod level
set:
defaultPodOptions:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: topology.kubernetes.io/zone
operator: In
values:
- antarctica-east1
- antarctica-west1
controllers:
main:
pod:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: topology.kubernetes.io/zone
operator: In
values:
- asia-east1
- asia-west1
documentSelector: *DeploymentSelector
asserts:
- equal:
path: spec.template.spec.affinity
value:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: topology.kubernetes.io/zone
operator: In
values:
- asia-east1
- asia-west1
- it: affinity can be configured with templated valued
set:
controllers:
main:
pod:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- "{{ .Release.Name }}"
topologyKey: kubernetes.io/hostname
documentSelector: *DeploymentSelector
asserts:
- equal:
path: spec.template.spec.affinity
value:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- RELEASE-NAME
topologyKey: kubernetes.io/hostname

View file

@ -0,0 +1,61 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod dnsConfig
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.dnsConfig
- it: defaultPodOption should pass
set:
defaultPodOptions:
dnsConfig:
options:
- name: ndots
value: "1"
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.dnsConfig
value:
options:
- name: ndots
value: "1"
- it: defaultPodOption with pod override should pass
set:
defaultPodOptions:
dnsConfig:
options:
- name: ndots
value: "1"
controllers:
main:
pod:
dnsConfig:
options:
- name: ndots
value: "5"
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.dnsConfig
value:
options:
- name: ndots
value: "5"

View file

@ -0,0 +1,43 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod dnsPolicy
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.dnsPolicy
value: ClusterFirst
- it: hostNetwork enabled should pass
set:
defaultPodOptions:
hostNetwork: true
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.dnsPolicy
value: ClusterFirstWithHostNet
- it: custom dnsPolicy should pass
set:
defaultPodOptions:
dnsPolicy: None
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.dnsPolicy
value: None

View file

@ -0,0 +1,41 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod enableServiceLinks
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.enableServiceLinks
value: false
- it: enabled in defaultPodOptions should pass
set:
defaultPodOptions.enableServiceLinks: true
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.enableServiceLinks
value: true
- it: enabled in pod options should pass
set:
controllers.main.pod.enableServiceLinks: true
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.enableServiceLinks
value: true

View file

@ -0,0 +1,64 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod hostAliases
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.hostAliases
- it: defaultPodOption should pass
set:
defaultPodOptions:
hostAliases:
- ip: "192.168.1.100"
hostnames:
- "example.com"
- "www.example.com"
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.hostAliases
value:
- ip: "192.168.1.100"
hostnames:
- "example.com"
- "www.example.com"
- it: defaultPodOption with pod override should pass
set:
defaultPodOptions:
hostAliases:
- ip: "192.168.1.100"
hostnames:
- "example.com"
- "www.example.com"
controllers:
main:
pod:
hostAliases:
- ip: "127.0.0.1"
hostnames:
- "localhost"
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.hostAliases
value:
- ip: "127.0.0.1"
hostnames:
- "localhost"

View file

@ -0,0 +1,43 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod security
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.hostIPC
value: false
- it: hostIPC disabled should pass
set:
defaultPodOptions:
hostIPC: false
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.hostIPC
value: false
- it: hostIPC enabled should pass
set:
defaultPodOptions:
hostIPC: true
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.hostIPC
value: true

View file

@ -0,0 +1,43 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod hostNetwork
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.hostNetwork
value: false
- it: hostNetwork disabled should pass
set:
defaultPodOptions:
hostNetwork: false
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.hostNetwork
value: false
- it: hostNetwork enabled should pass
set:
defaultPodOptions:
hostNetwork: true
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.hostNetwork
value: true

View file

@ -0,0 +1,43 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod security
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.hostPID
value: false
- it: hostPID disabled should pass
set:
defaultPodOptions:
hostPID: false
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.hostPID
value: false
- it: hostPID enabled should pass
set:
defaultPodOptions:
hostPID: true
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.hostPID
value: true

View file

@ -0,0 +1,59 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod security
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
capabilities:
majorVersion: 1
minorVersion: 29
tests:
- it: should not be present by default for kubernetes < 1.28
capabilities:
majorVersion: 1
minorVersion: 28
documentSelector: &DeploymentSelector
path: $[?(@.kind == "Deployment")].metadata.name
value: RELEASE-NAME
asserts:
- notExists:
path: spec.template.spec.hostUsers
- it: should not be present even if specified for kubernetes < 1.28
capabilities:
majorVersion: 1
minorVersion: 28
set:
defaultPodOptions:
hostUsers: false
documentSelector: *DeploymentSelector
asserts:
- notExists:
path: spec.template.spec.hostUsers
- it: should not be present by default for kubernetes >= 1.29
documentSelector: *DeploymentSelector
asserts:
- notExists:
path: spec.template.spec.hostUsers
- it: hostUsers disabled should set for kubernetes >= 1.29
set:
defaultPodOptions:
hostUsers: false
documentSelector: *DeploymentSelector
asserts:
- equal:
path: spec.template.spec.hostUsers
value: false
- it: hostUsers enabled should be set for kubernetes >= 1.29
set:
defaultPodOptions:
hostUsers: true
documentSelector: *DeploymentSelector
asserts:
- equal:
path: spec.template.spec.hostUsers
value: true

View file

@ -0,0 +1,51 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod imagePullSecrets
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.imagePullSecrets
- it: defaultPodOption should pass
set:
defaultPodOptions:
imagePullSecrets:
- name: my-pull-secret
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.imagePullSecrets
value:
- name: my-pull-secret
- it: defaultPodOption with pod override should pass
set:
defaultPodOptions:
imagePullSecrets:
- name: my-pull-secret
controllers:
main:
pod:
imagePullSecrets:
- name: my-other-secret
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.imagePullSecrets
value:
- name: my-other-secret

View file

@ -0,0 +1,51 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod nodeSelector
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.nodeSelector
- it: defaultPodOption should pass
set:
defaultPodOptions:
nodeSelector:
disktype: ssd
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.nodeSelector
value:
disktype: ssd
- it: defaultPodOption with pod override should pass
set:
defaultPodOptions:
nodeSelector:
disktype: ssd
controllers:
main:
pod:
nodeSelector:
disktype: hdd
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.nodeSelector
value:
disktype: hdd

View file

@ -0,0 +1,40 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod replicas
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.replicas
value: 1
- it: nil should pass
set:
controllers.main.replicas: null
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
notExists:
path: spec.replicas
- it: custom replicas should pass
set:
controllers.main.replicas: 3
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.replicas
value: 3

View file

@ -0,0 +1,66 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod 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.securityContext
- it: defaultPodOption should pass
set:
defaultPodOptions:
securityContext:
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
fsGroupChangePolicy: OnRootMismatch
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.securityContext
value:
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
fsGroupChangePolicy: OnRootMismatch
- it: defaultPodOption with pod override should pass
set:
defaultPodOptions:
securityContext:
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
fsGroupChangePolicy: OnRootMismatch
controllers:
main:
pod:
securityContext:
runAsUser: 568
runAsGroup: 568
fsGroup: 568
fsGroupChangePolicy: OnRootMismatch
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.securityContext
value:
runAsUser: 568
runAsGroup: 568
fsGroup: 568
fsGroupChangePolicy: OnRootMismatch

View file

@ -0,0 +1,174 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod serviceAccount
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default should pass
asserts:
- hasDocuments:
count: 1
- documentIndex: &deploymentDocument 0
isKind:
of: Deployment
- documentIndex: *deploymentDocument
equal:
path: spec.template.spec.serviceAccountName
value: default
- it: default with flag should pass
set:
enforceServiceAccountCreation: true
asserts:
- hasDocuments:
count: 1
- documentIndex: &deploymentDocument 0
isKind:
of: Deployment
- documentIndex: *deploymentDocument
equal:
path: spec.template.spec.serviceAccountName
value: default
- it: with create, without name should pass
set:
serviceAccount:
create: true
asserts:
- hasDocuments:
count: 3
- documentIndex: &serviceAccountDocument 0
isKind:
of: ServiceAccount
- documentIndex: &deploymentDocument 1
isKind:
of: Deployment
- documentIndex: *deploymentDocument
equal:
path: spec.template.spec.serviceAccountName
value: RELEASE-NAME
- it: with create, with name should pass
set:
serviceAccount:
create: true
name: mySA
asserts:
- hasDocuments:
count: 3
- documentIndex: &serviceAccountDocument 0
isKind:
of: ServiceAccount
- documentIndex: &deploymentDocument 1
isKind:
of: Deployment
- documentIndex: *deploymentDocument
equal:
path: spec.template.spec.serviceAccountName
value: mySA
- it: without create, with name should pass
set:
serviceAccount:
create: false
name: &serviceAccountName mySA
asserts:
- hasDocuments:
count: 1
- documentIndex: &deploymentDocument 0
isKind:
of: Deployment
- documentIndex: *deploymentDocument
equal:
path: spec.template.spec.serviceAccountName
value: *serviceAccountName
- it: without create, with name, with flag should pass
set:
enforceServiceAccountCreation: true
serviceAccount:
create: false
name: &serviceAccountName mySA
asserts:
- hasDocuments:
count: 1
- documentIndex: &deploymentDocument 0
isKind:
of: Deployment
- documentIndex: *deploymentDocument
equal:
path: spec.template.spec.serviceAccountName
value: default
- it: with extraServiceAccounts default should pass
set:
serviceAccount:
create: false
name: &serviceAccountName mySA
extraServiceAccounts:
mySA2:
create: false
mySA3:
create: true
asserts:
- hasDocuments:
count: 3
- documentIndex: &deploymentDocument 1
isKind:
of: Deployment
- documentIndex: *deploymentDocument
equal:
path: spec.template.spec.serviceAccountName
value: *serviceAccountName
- it: with extraServiceAccounts identifier should pass
set:
controllers:
main:
serviceAccount:
identifier: mySA3
serviceAccount:
create: false
name: mySA
extraServiceAccounts:
mySA2:
create: false
mySA3:
create: true
asserts:
- hasDocuments:
count: 3
- documentIndex: &deploymentDocument 1
isKind:
of: Deployment
- documentIndex: *deploymentDocument
equal:
path: spec.template.spec.serviceAccountName
value: RELEASE-NAME-mySA3
- it: with extraServiceAccounts name should pass
set:
controllers:
main:
serviceAccount:
name: arbitrary-SA
serviceAccount:
create: false
name: mySA
extraServiceAccounts:
mySA2:
create: false
mySA3:
create: true
asserts:
- hasDocuments:
count: 3
- documentIndex: &deploymentDocument 1
isKind:
of: Deployment
- documentIndex: *deploymentDocument
equal:
path: spec.template.spec.serviceAccountName
value: arbitrary-SA

View file

@ -0,0 +1,35 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod security
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: shareProcessNamespace should not be present by default
documentSelector: &DeploymentSelector
path: $[?(@.kind == "Deployment")].metadata.name
value: RELEASE-NAME
asserts:
- notExists:
path: spec.template.spec.shareProcessNamespace
- it: shareProcessNamespace disabled should pass
set:
defaultPodOptions:
shareProcessNamespace: false
documentSelector: *DeploymentSelector
asserts:
- equal:
path: spec.template.spec.shareProcessNamespace
value: false
- it: shareProcessNamespace enabled should pass
set:
defaultPodOptions:
shareProcessNamespace: true
documentSelector: *DeploymentSelector
asserts:
- equal:
path: spec.template.spec.shareProcessNamespace
value: true

View file

@ -0,0 +1,66 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod tolerations
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.tolerations
- it: defaultPodOption should pass
set:
defaultPodOptions:
tolerations:
- key: "key1"
operator: "Equal"
value: "value1"
effect: "NoSchedule"
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.tolerations
value:
- key: "key1"
operator: "Equal"
value: "value1"
effect: "NoSchedule"
- it: defaultPodOption with pod override should pass
set:
defaultPodOptions:
tolerations:
- key: "key1"
operator: "Equal"
value: "value1"
effect: "NoSchedule"
controllers:
main:
pod:
tolerations:
- key: "master"
operator: "Equal"
value: "value1"
effect: "NoSchedule"
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.tolerations
value:
- key: "master"
operator: "Equal"
value: "value1"
effect: "NoSchedule"

View file

@ -0,0 +1,76 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod topologySpreadConstraints
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.topologySpreadConstraints
- it: defaultPodOption should pass
set:
defaultPodOptions:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: foo
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.topologySpreadConstraints
value:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: foo
- it: defaultPodOption with pod override should pass
set:
defaultPodOptions:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: foo
controllers:
main:
pod:
topologySpreadConstraints:
- maxSkew: 2
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: foo
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.topologySpreadConstraints
value:
- maxSkew: 2
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: foo

View file

@ -0,0 +1,118 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod initContainers
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: with custom env vars dict should pass
set:
controllers.main.initContainers:
init1:
image:
repository: ghcr.io/mendhak/http-https-echo
tag: latest
env:
int: 1
float: 1.5
string: value_of_env
template: "{{ .Release.Name }}-admin"
asserts:
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.initContainers[0].env[0]
value:
name: float
value: "1.5"
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.initContainers[0].env[1]
value:
name: int
value: "1"
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.initContainers[0].env[2]
value:
name: string
value: value_of_env
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.initContainers[0].env[3]
value:
name: template
value: RELEASE-NAME-admin
- it: disabled should pass
set:
controllers.main.initContainers:
init1:
enabled: false
image:
repository: ghcr.io/mendhak/http-https-echo
tag: test
asserts:
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
notExists:
path: spec.template.spec.initContainers
- it: with dependsOn
set:
controllers.main.initContainers:
init1:
dependsOn: init2
image:
repository: ghcr.io/mendhak/http-https-echo
tag: latest
init2:
image:
repository: ghcr.io/mendhak/http-https-echo
tag: latest
asserts:
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
lengthEqual:
path: spec.template.spec.initContainers
count: 2
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.initContainers[0].name
value: init2
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.initContainers[1].name
value: init1
- it: with custom restartPolicy (sidecar)
set:
controllers.main.initContainers:
test:
image:
repository: ghcr.io/mendhak/http-https-echo
tag: latest
restartPolicy: Always
asserts:
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
lengthEqual:
path: spec.template.spec.initContainers
count: 1
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.initContainers[0].name
value: test
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.initContainers[0].restartPolicy
value: Always

View file

@ -0,0 +1,66 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: "pod metadata: annotations"
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default pod annotations
documentSelector: &DeploymentSelector
path: $[?(@.kind == "Deployment")].metadata.name
value: RELEASE-NAME
asserts:
- notExists:
path: spec.template.metadata.annotations
- it: pod annotations from defaultPodOptions should be included
set:
defaultPodOptions:
annotations:
defaultPodOptionsAnnotation: test
documentSelector: *DeploymentSelector
asserts:
- isSubset:
path: spec.template.metadata.annotations
content:
defaultPodOptionsAnnotation: test
- it: pod annotations from pod options should be included
set:
controllers:
main:
pod:
annotations:
podOptionsAnnotation: test
documentSelector: *DeploymentSelector
asserts:
- isSubset:
path: spec.template.metadata.annotations
content:
podOptionsAnnotation: test
- it: pod annotations from global annotations should not be included by default
set:
global:
annotations:
globalAnnotation: test
documentSelector: *DeploymentSelector
asserts:
- isNotSubset:
path: spec.template.metadata.annotations
content:
globalAnnotation: test
- it: pod annotations from global annotations should be included when requested
set:
global:
propagateGlobalMetadataToPods: true
annotations:
globalAnnotation: test
documentSelector: *DeploymentSelector
asserts:
- isSubset:
path: spec.template.metadata.annotations
content:
globalAnnotation: test

View file

@ -0,0 +1,70 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: "pod metadata: labels"
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default pod labels
documentSelector: &DeploymentSelector
path: $[?(@.kind == "Deployment")].metadata.name
value: RELEASE-NAME
asserts:
- equal:
path: spec.template.metadata.labels
value:
app.kubernetes.io/component: main
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: RELEASE-NAME
- it: pod labels from defaultPodOptions should be included
set:
defaultPodOptions:
labels:
defaultPodOptionsLabel: test
documentSelector: *DeploymentSelector
asserts:
- isSubset:
path: spec.template.metadata.labels
content:
defaultPodOptionsLabel: test
- it: pod labels from pod options should be included
set:
controllers:
main:
pod:
labels:
podOptionsLabel: test
documentSelector: *DeploymentSelector
asserts:
- isSubset:
path: spec.template.metadata.labels
content:
podOptionsLabel: test
- it: pod labels from global labels should not be included by default
set:
global:
labels:
globalLabel: test
documentSelector: *DeploymentSelector
asserts:
- isNotSubset:
path: spec.template.metadata.labels
content:
globalLabel: test
- it: pod labels from global labels should be included when requested
set:
global:
propagateGlobalMetadataToPods: true
labels:
globalLabel: test
documentSelector: *DeploymentSelector
asserts:
- isSubset:
path: spec.template.metadata.labels
content:
globalLabel: test