feat: Bump common library to v3.4.0 (#349)

This commit is contained in:
Bernd Schorgers 2024-08-27 14:16:37 +02:00
parent a78c21ab00
commit 86062681a9
No known key found for this signature in database
GPG key ID: BC5E2BD907F9A8EC
45 changed files with 1023 additions and 149 deletions

View file

@ -0,0 +1,2 @@
#! /bin/bash
echo "Hello!"

View file

@ -0,0 +1,2 @@
test:
test: "{{ .Values.configMapsFromFolderBasePath }}"

View file

@ -0,0 +1,2 @@
test:
test: "{{ .Values.configMapsFromFolderBasePath }}"

View file

@ -6,4 +6,3 @@ controllers:
image:
repository: ghcr.io/mendhak/http-https-echo
tag: 31
pullPolicy: IfNotPresent

View file

@ -98,3 +98,56 @@ tests:
global_label: test
helm.sh/chart: common-test-1.0.0
test_label: test
- it: default metadata from folder should pass
set:
configMaps:
config:
data:
test: test
configMapsFromFolderBasePath: ci/configMapsFolder
asserts:
- hasDocuments:
count: 4
- documentIndex: &FirstConfigmapDocument 1
isKind:
of: ConfigMap
- documentIndex: *FirstConfigmapDocument
notExists:
path: metadata.annotations
- documentIndex: *FirstConfigmapDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: common-test-1.0.0
- documentIndex: &SecondConfigmapDocument 2
isKind:
of: ConfigMap
- documentIndex: *SecondConfigmapDocument
notExists:
path: metadata.annotations
- documentIndex: *SecondConfigmapDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: common-test-1.0.0
- documentIndex: &ThirdConfigmapDocument 3
isKind:
of: ConfigMap
- documentIndex: *ThirdConfigmapDocument
notExists:
path: metadata.annotations
- documentIndex: *ThirdConfigmapDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: common-test-1.0.0

View file

@ -107,3 +107,36 @@ tests:
equal:
path: metadata.name
value: RELEASE-NAME
- it: with templated nameOverride and from folder should pass
set:
configMaps:
config:
data:
test: test
nameOverride: "{{ .Release.Name }}"
configMapsFromFolderBasePath: ci/configMapsFolder
asserts:
- hasDocuments:
count: 4
- documentIndex: &FirstConfigmapDocument 1
isKind:
of: ConfigMap
- documentIndex: *FirstConfigmapDocument
equal:
path: metadata.name
value: RELEASE-NAME
- documentIndex: &SecondConfigmapDocument 2
isKind:
of: ConfigMap
- documentIndex: *SecondConfigmapDocument
equal:
path: metadata.name
value: RELEASE-NAME-test_1
- documentIndex: &ThirdConfigmapDocument 3
isKind:
of: ConfigMap
- documentIndex: *ThirdConfigmapDocument
equal:
path: metadata.name
value: RELEASE-NAME-test_2

View file

@ -75,3 +75,35 @@ tests:
- 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

@ -73,3 +73,35 @@ tests:
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

@ -237,3 +237,37 @@ tests:
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

@ -41,6 +41,61 @@ tests:
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:

View file

@ -3,10 +3,10 @@
suite: container image tag
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.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
@ -21,6 +21,8 @@ tests:
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
@ -35,6 +37,8 @@ tests:
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
@ -47,3 +51,38 @@ tests:
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,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,136 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: controller defaultContainerOptions
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 with implicit strategy should pass
set:
controllers.main.defaultContainerOptions:
resources:
requests:
memory: 1Gi
cpu: 150m
controllers.main.containers.main.resources:
requests:
memory: 2Gi
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].resources
value:
requests:
memory: 2Gi
- it: defaultContainerOption with overwrite strategy should pass
set:
controllers.main.defaultContainerOptionsStrategy: overwrite
controllers.main.defaultContainerOptions:
resources:
requests:
memory: 1Gi
cpu: 150m
controllers.main.containers.main.resources:
requests:
memory: 2Gi
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].resources
value:
requests:
memory: 2Gi
- it: defaultContainerOption with merge strategy should pass
set:
controllers.main.defaultContainerOptionsStrategy: merge
controllers.main.defaultContainerOptions:
resources:
requests:
memory: 1Gi
cpu: 150m
controllers.main.containers.main.resources:
requests:
memory: 2Gi
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].resources
value:
requests:
memory: 2Gi
cpu: 150m
- it: Default applyDefaultContainerOptionsToInitContainers (true) should pass
set:
controllers.main.defaultContainerOptions:
resources:
requests:
memory: 1Gi
controllers.main.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: applyDefaultContainerOptionsToInitContainers false should pass
set:
controllers.main.applyDefaultContainerOptionsToInitContainers: false
controllers.main.defaultContainerOptions:
resources:
requests:
memory: 1Gi
controllers.main.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