mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-04 00:47:04 +02:00
feat(common): Release common library 3.7.1 (#383)
Co-authored-by: Aisling McGinn <me@aisling.dev>
This commit is contained in:
parent
c94a28baa3
commit
433f6d132b
146 changed files with 232 additions and 222 deletions
33
charts/library/common/test-chart/.helmignore
Normal file
33
charts/library/common/test-chart/.helmignore
Normal file
|
@ -0,0 +1,33 @@
|
|||
# Patterns to ignore when building packages.
|
||||
# This supports shell glob matching, relative path matching, and
|
||||
# negation (prefixed with !). Only one pattern per line.
|
||||
.DS_Store
|
||||
# Common VCS dirs
|
||||
.git/
|
||||
.gitignore
|
||||
.bzr/
|
||||
.bzrignore
|
||||
.hg/
|
||||
.hgignore
|
||||
.svn/
|
||||
# Common backup files
|
||||
*.swp
|
||||
*.bak
|
||||
*.tmp
|
||||
*~
|
||||
# Various IDEs
|
||||
.project
|
||||
.idea/
|
||||
*.tmproj
|
||||
.vscode/
|
||||
# OWNERS file for Kubernetes
|
||||
OWNERS
|
||||
# helm-docs templates
|
||||
*.gotmpl
|
||||
|
||||
# Schema files
|
||||
schemas/
|
||||
|
||||
# Test files
|
||||
test-chart/
|
||||
unittests/
|
13
charts/library/common/test-chart/Chart.yaml
Normal file
13
charts/library/common/test-chart/Chart.yaml
Normal file
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
apiVersion: v2
|
||||
description: A helper chart that is used to test the common library chart
|
||||
name: common-test
|
||||
version: 1.0.0
|
||||
kubeVersion: ">=1.22.0-0"
|
||||
maintainers:
|
||||
- name: bjw-s
|
||||
email: me@bjw-s.dev
|
||||
dependencies:
|
||||
- name: common
|
||||
repository: file://../
|
||||
version: ">0.0.0-0"
|
1
charts/library/common/test-chart/ci/.gitignore
vendored
Normal file
1
charts/library/common/test-chart/ci/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
test-values.yaml
|
110
charts/library/common/test-chart/ci/advanced-values.yaml
Normal file
110
charts/library/common/test-chart/ci/advanced-values.yaml
Normal file
|
@ -0,0 +1,110 @@
|
|||
---
|
||||
# yaml-language-server: $schema=../../common/values.schema.json
|
||||
controllers:
|
||||
main:
|
||||
containers:
|
||||
main:
|
||||
image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
tag: 31
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
env:
|
||||
HTTP_PORT: 8887
|
||||
HTTPS_PORT: 9997
|
||||
|
||||
probes:
|
||||
liveness:
|
||||
enabled: true
|
||||
readiness:
|
||||
enabled: true
|
||||
startup:
|
||||
enabled: true
|
||||
|
||||
a-container:
|
||||
dependsOn:
|
||||
- main
|
||||
- third-container
|
||||
image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
tag: 31
|
||||
env:
|
||||
HTTP_PORT: 8888
|
||||
HTTPS_PORT: 9998
|
||||
|
||||
third-container:
|
||||
dependsOn: main
|
||||
image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
tag: 31
|
||||
|
||||
second-controller:
|
||||
type: deployment
|
||||
containers:
|
||||
main:
|
||||
image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
tag: 31
|
||||
pullPolicy: IfNotPresent
|
||||
env:
|
||||
HTTP_PORT: 8889
|
||||
HTTPS_PORT: 9999
|
||||
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
port: 8887
|
||||
|
||||
ingress:
|
||||
main:
|
||||
hosts:
|
||||
- host: "test.local"
|
||||
paths:
|
||||
- path: /
|
||||
service:
|
||||
identifier: main
|
||||
port: http
|
||||
tls:
|
||||
- hosts:
|
||||
- "test.local"
|
||||
|
||||
configMaps:
|
||||
config:
|
||||
enabled: true
|
||||
data:
|
||||
test: value 1
|
||||
|
||||
persistence:
|
||||
data:
|
||||
type: configMap
|
||||
name: |-
|
||||
{{- (include "bjw-s.common.lib.chart.names.fullname" $) -}}-config
|
||||
advancedMounts:
|
||||
main: # the controller with the "main" identifier
|
||||
main: # the container with the "main" identifier
|
||||
- path: /data/config.yaml
|
||||
readOnly: false
|
||||
subPath: config.yaml
|
||||
second-container: # the container with the "second-container" identifier
|
||||
- path: /appdata/config
|
||||
readOnly: true
|
||||
second-controller: # the controller with the "second-controller" identifier
|
||||
main: # the container with the "main" identifier
|
||||
- path: /data/config.yaml
|
||||
readOnly: false
|
||||
subPath: config.yaml
|
||||
|
||||
rawResources:
|
||||
unsupportedPDB:
|
||||
enabled: true
|
||||
nameOverride: pdb
|
||||
apiVersion: policy/v1
|
||||
kind: PodDisruptionBudget
|
||||
spec:
|
||||
spec:
|
||||
minAvailable: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/instance: "{{ .Release.Name }}"
|
44
charts/library/common/test-chart/ci/basic-values.yaml
Normal file
44
charts/library/common/test-chart/ci/basic-values.yaml
Normal file
|
@ -0,0 +1,44 @@
|
|||
---
|
||||
# yaml-language-server: $schema=../../common/values.schema.json
|
||||
controllers:
|
||||
main:
|
||||
containers:
|
||||
main:
|
||||
image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
tag: 31
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
probes:
|
||||
liveness:
|
||||
enabled: true
|
||||
readiness:
|
||||
enabled: true
|
||||
startup:
|
||||
enabled: true
|
||||
|
||||
ingress:
|
||||
main:
|
||||
hosts:
|
||||
- host: "test.local"
|
||||
paths:
|
||||
- path: /
|
||||
service:
|
||||
identifier: main
|
||||
port: http
|
||||
tls:
|
||||
- hosts:
|
||||
- "test.local"
|
||||
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
port: 8080
|
||||
|
||||
persistence:
|
||||
media:
|
||||
type: persistentVolumeClaim
|
||||
accessMode: ReadWriteOnce
|
||||
size: 1Gi
|
|
@ -0,0 +1,2 @@
|
|||
#! /bin/bash
|
||||
echo "Hello!"
|
|
@ -0,0 +1,2 @@
|
|||
test:
|
||||
test: "{{ .Values.configMapsFromFolderBasePath }}"
|
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
|
@ -0,0 +1,2 @@
|
|||
test:
|
||||
test: "{{ .Values.global.random.nonExistentKey }}"
|
20
charts/library/common/test-chart/ci/cronjob-values.yaml
Normal file
20
charts/library/common/test-chart/ci/cronjob-values.yaml
Normal file
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
# yaml-language-server: $schema=../../common/values.schema.json
|
||||
controllers:
|
||||
main:
|
||||
type: cronjob
|
||||
cronjob:
|
||||
timeZone: UTC
|
||||
schedule: "*/20 * * * *"
|
||||
containers:
|
||||
main:
|
||||
image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
tag: 31
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
configMaps:
|
||||
config:
|
||||
enabled: true
|
||||
data:
|
||||
test: value 1
|
10
charts/library/common/test-chart/ci/no-service.yaml
Normal file
10
charts/library/common/test-chart/ci/no-service.yaml
Normal file
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
# yaml-language-server: $schema=../../common/values.schema.json
|
||||
controllers:
|
||||
main:
|
||||
containers:
|
||||
main:
|
||||
image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
tag: 31
|
||||
pullPolicy: IfNotPresent
|
64
charts/library/common/test-chart/ci/vaultwarden-example.yaml
Normal file
64
charts/library/common/test-chart/ci/vaultwarden-example.yaml
Normal file
|
@ -0,0 +1,64 @@
|
|||
---
|
||||
# yaml-language-server: $schema=../../common/values.schema.json
|
||||
controllers:
|
||||
main:
|
||||
strategy: Recreate
|
||||
|
||||
containers:
|
||||
main:
|
||||
image:
|
||||
# -- image repository
|
||||
repository: vaultwarden/server
|
||||
# -- image tag
|
||||
# this example is not automatically updated, so be sure to use the latest image
|
||||
tag: 1.25.2
|
||||
# -- image pull policy
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
# -- environment variables.
|
||||
# See [image docs](https://github.com/dani-garcia/vaultwarden/blob/main/.env.template) for more details.
|
||||
env:
|
||||
# -- Config dir
|
||||
DATA_FOLDER: "config"
|
||||
|
||||
# -- Configures service settings for the chart.
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
port: 80
|
||||
websocket:
|
||||
enabled: true
|
||||
port: 3012
|
||||
|
||||
ingress:
|
||||
# -- Enable and configure ingress settings for the chart under this key.
|
||||
main:
|
||||
hosts:
|
||||
- host: chart-example.local
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
service:
|
||||
name: main
|
||||
port: http
|
||||
- path: /notifications/hub/negotiate
|
||||
pathType: Prefix
|
||||
service:
|
||||
name: main
|
||||
port: http
|
||||
- path: /notifications/hub
|
||||
pathType: Prefix
|
||||
service:
|
||||
name: main
|
||||
port: websocket
|
||||
|
||||
# -- Configure persistence settings for the chart under this key.
|
||||
persistence:
|
||||
config:
|
||||
type: persistentVolumeClaim
|
||||
accessMode: ReadWriteOnce
|
||||
size: 1Gi
|
||||
globalMounts:
|
||||
- path: /config
|
14
charts/library/common/test-chart/templates/common.yaml
Normal file
14
charts/library/common/test-chart/templates/common.yaml
Normal file
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
{{- include "bjw-s.common.loader.init" . }}
|
||||
|
||||
{{- define "app-template.hardcodedValues" -}}
|
||||
# Set the nameOverride based on the release name if no override has been set
|
||||
{{ if not .Values.global.nameOverride }}
|
||||
global:
|
||||
nameOverride: "{{ .Release.Name }}"
|
||||
{{ end }}
|
||||
{{- end -}}
|
||||
{{- $_ := mergeOverwrite .Values (include "app-template.hardcodedValues" . | fromYaml) -}}
|
||||
|
||||
{{/* Render the templates */}}
|
||||
{{ include "bjw-s.common.loader.generate" . }}
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
controllers:
|
||||
main:
|
||||
containers:
|
||||
main:
|
||||
image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
tag: 31
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
# yaml-language-server: $schema=../../../common/values.schema.json
|
||||
ingress:
|
||||
main:
|
||||
hosts:
|
||||
- host: "chart-example.local"
|
||||
paths:
|
||||
- path: /
|
||||
service:
|
||||
name: RELEASE-NAME
|
||||
port: 8081
|
|
@ -0,0 +1,19 @@
|
|||
serviceAccount:
|
||||
create: true
|
||||
|
||||
rbac:
|
||||
roles:
|
||||
defaultRole:
|
||||
type: Role
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["pods"]
|
||||
verbs: ["get", "list"]
|
||||
|
||||
bindings:
|
||||
defaultBinding:
|
||||
type: RoleBinding
|
||||
roleRef:
|
||||
identifier: defaultRole
|
||||
subjects:
|
||||
- identifier: default
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
# yaml-language-server: $schema=../../../common/values.schema.json
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
port: 8081
|
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: Chart validations
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: advancedMounts invalid controller reference should fail
|
||||
set:
|
||||
persistence:
|
||||
data:
|
||||
type: configMap
|
||||
name: myConfigMap
|
||||
advancedMounts:
|
||||
test:
|
||||
main:
|
||||
- path: /data/config.yaml
|
||||
readOnly: false
|
||||
mountPropagation: HostToContainer
|
||||
subPath: config.yaml
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: "No enabled controller found with this identifier. (persistence item: 'data', controller: 'test')"
|
|
@ -0,0 +1,238 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: configmap metadata
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default metadata should pass
|
||||
set:
|
||||
configMaps:
|
||||
config:
|
||||
data:
|
||||
test: test
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &ConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *ConfigmapDocument
|
||||
notExists:
|
||||
path: metadata.annotations
|
||||
- documentIndex: *ConfigmapDocument
|
||||
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
|
||||
|
||||
- it: custom metadata should pass
|
||||
set:
|
||||
configMaps:
|
||||
config:
|
||||
data:
|
||||
test: test
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &ConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *ConfigmapDocument
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
test_annotation: test
|
||||
- documentIndex: *ConfigmapDocument
|
||||
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
|
||||
test_label: test
|
||||
|
||||
- it: custom metadata with global metadata should pass
|
||||
set:
|
||||
global:
|
||||
labels:
|
||||
global_label: test
|
||||
annotations:
|
||||
global_annotation: test
|
||||
configMaps:
|
||||
config:
|
||||
data:
|
||||
test: test
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &ConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *ConfigmapDocument
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
global_annotation: test
|
||||
test_annotation: test
|
||||
- documentIndex: *ConfigmapDocument
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
global_label: test
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
test_label: test
|
||||
|
||||
- it: default configuration from folder with binary files should fail
|
||||
set:
|
||||
configMaps:
|
||||
config:
|
||||
data:
|
||||
test: test
|
||||
configMapsFromFolder:
|
||||
enabled: true
|
||||
basePath: ci/configMapsFolder
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: "There was an error loading ConfigMap: test_2. If it was automatically generated from a folder verify that files are properly flagged as `binary` or `escaped`"
|
||||
|
||||
- it: default metadata from folder should pass
|
||||
set:
|
||||
configMaps:
|
||||
config:
|
||||
data:
|
||||
test: test
|
||||
configMapsFromFolder:
|
||||
enabled: true
|
||||
basePath: ci/configMapsFolder
|
||||
configMapsOverrides:
|
||||
test_2:
|
||||
fileAttributeOverrides:
|
||||
helm.jpg:
|
||||
binary: true
|
||||
test_2.yaml:
|
||||
escaped: true
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 4
|
||||
- documentIndex: &FirstConfigmapDocument 0
|
||||
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 1
|
||||
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 2
|
||||
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
|
||||
|
||||
- it: custom metadata from folder should pass
|
||||
set:
|
||||
configMaps:
|
||||
config:
|
||||
data:
|
||||
test: test
|
||||
configMapsFromFolder:
|
||||
enabled: true
|
||||
basePath: ci/configMapsFolder
|
||||
configMapsOverrides:
|
||||
test_2:
|
||||
labels:
|
||||
test: test_label
|
||||
annotations:
|
||||
test: test_annotation
|
||||
fileAttributeOverrides:
|
||||
helm.jpg:
|
||||
binary: true
|
||||
test_2.yaml:
|
||||
escaped: true
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 4
|
||||
- documentIndex: &FirstConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- 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 1
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- 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 2
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- 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
|
||||
test: test_label
|
||||
- documentIndex: *ThirdConfigmapDocument
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
test: test_annotation
|
|
@ -0,0 +1,196 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: configMap names
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default should pass
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- documentIndex: 0
|
||||
not: true
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
|
||||
- it: with disabled configMap should pass
|
||||
set:
|
||||
configMaps:
|
||||
config:
|
||||
enabled: false
|
||||
data:
|
||||
test: test
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- documentIndex: 0
|
||||
not: true
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
|
||||
- it: with multiple configMap should pass
|
||||
set:
|
||||
configMaps:
|
||||
config:
|
||||
data:
|
||||
foo: bar
|
||||
secondary:
|
||||
data:
|
||||
test: test
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 3
|
||||
- documentIndex: &FirstConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *FirstConfigmapDocument
|
||||
isNotNullOrEmpty:
|
||||
path: metadata.name
|
||||
- documentIndex: &SecondConfigmapDocument 1
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *SecondConfigmapDocument
|
||||
isNotNullOrEmpty:
|
||||
path: metadata.name
|
||||
|
||||
- it: default name should pass
|
||||
set:
|
||||
configMaps:
|
||||
config:
|
||||
data:
|
||||
test: test
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &ConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *ConfigmapDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-config
|
||||
|
||||
- it: with nameOverride should pass
|
||||
set:
|
||||
configMaps:
|
||||
config:
|
||||
data:
|
||||
test: test
|
||||
nameOverride: http
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &ConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *ConfigmapDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-http
|
||||
|
||||
- it: with templated nameOverride should pass
|
||||
set:
|
||||
configMaps:
|
||||
config:
|
||||
data:
|
||||
test: test
|
||||
nameOverride: "{{ .Release.Name }}"
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &ConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *ConfigmapDocument
|
||||
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 }}"
|
||||
configMapsFromFolder:
|
||||
enabled: true
|
||||
basePath: ci/configMapsFolder
|
||||
configMapsOverrides:
|
||||
test_2:
|
||||
fileAttributeOverrides:
|
||||
helm.jpg:
|
||||
binary: true
|
||||
test_2.yaml:
|
||||
escaped: true
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 4
|
||||
- documentIndex: &FirstConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *FirstConfigmapDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
- documentIndex: &SecondConfigmapDocument 1
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *SecondConfigmapDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-test_1
|
||||
- documentIndex: &ThirdConfigmapDocument 2
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *ThirdConfigmapDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-test_2
|
||||
|
||||
- it: with templated nameOverride and from folder with forceRename should pass
|
||||
set:
|
||||
configMaps:
|
||||
config:
|
||||
data:
|
||||
test: test
|
||||
nameOverride: "{{ .Release.Name }}"
|
||||
configMapsFromFolder:
|
||||
enabled: true
|
||||
basePath: ci/configMapsFolder
|
||||
configMapsOverrides:
|
||||
test_1:
|
||||
forceRename: &newName1 newName1
|
||||
test_2:
|
||||
forceRename: &newName2 newName2
|
||||
fileAttributeOverrides:
|
||||
helm.jpg:
|
||||
binary: true
|
||||
test_2.yaml:
|
||||
escaped: true
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 4
|
||||
- documentIndex: &FirstConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *FirstConfigmapDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
- documentIndex: &SecondConfigmapDocument 1
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *SecondConfigmapDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: *newName1
|
||||
- documentIndex: &ThirdConfigmapDocument 2
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *ThirdConfigmapDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: *newName2
|
|
@ -0,0 +1,73 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: configmap Pod metadata
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default metadata should pass
|
||||
set:
|
||||
configMaps:
|
||||
config:
|
||||
enabled: true
|
||||
data:
|
||||
test: value 1
|
||||
test_default_enabled:
|
||||
data:
|
||||
test: value 1
|
||||
test_not_in_checksum:
|
||||
includeInChecksum: false
|
||||
data:
|
||||
test: value 1
|
||||
test_disabled:
|
||||
enabled: false
|
||||
data:
|
||||
test: value 1
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 3
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.template.metadata.annotations
|
||||
value:
|
||||
checksum/configMaps: 66d23d7a53c4e2a523ba85a969696b4ebb78ec5d79ab9c12c210c1569f48511b
|
||||
|
||||
- it: default metadata from folder should pass
|
||||
set:
|
||||
configMaps:
|
||||
config:
|
||||
enabled: true
|
||||
data:
|
||||
test: value 1
|
||||
test_default_enabled:
|
||||
data:
|
||||
test: value 1
|
||||
test_not_in_checksum:
|
||||
includeInChecksum: false
|
||||
data:
|
||||
test: value 1
|
||||
test_disabled:
|
||||
enabled: false
|
||||
data:
|
||||
test: value 1
|
||||
configMapsFromFolder:
|
||||
enabled: true
|
||||
basePath: ci/configMapsFolder
|
||||
configMapsOverrides:
|
||||
test_2:
|
||||
fileAttributeOverrides:
|
||||
helm.jpg:
|
||||
binary: true
|
||||
test_2.yaml:
|
||||
escaped: true
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 5
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.template.metadata.annotations
|
||||
value:
|
||||
checksum/configMaps: e83a24569d0b4f2ccc44aec36d4e9a1c44a29bcc92eefdffe14fb1ce81dff054
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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)"
|
|
@ -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
|
|
@ -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
|
|
@ -0,0 +1,95 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: cronjob configuration
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default cronjob configuration should pass
|
||||
set:
|
||||
controllers.main.type: cronjob
|
||||
controllers.main.cronjob.schedule: "*/20 * * * *"
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: CronJob
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.suspend
|
||||
value: false
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.schedule
|
||||
value: "*/20 * * * *"
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.concurrencyPolicy
|
||||
value: Forbid
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.successfulJobsHistoryLimit
|
||||
value: 1
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.failedJobsHistoryLimit
|
||||
value: 1
|
||||
- documentIndex: *ControllerDoc
|
||||
notExists:
|
||||
path: spec.jobTemplate.spec.ttlSecondsAfterFinished
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.jobTemplate.spec.template.spec.restartPolicy
|
||||
value: Never
|
||||
|
||||
- it: custom cronjob configuration should pass
|
||||
set:
|
||||
controllers:
|
||||
main:
|
||||
type: cronjob
|
||||
pod:
|
||||
restartPolicy: OnFailure
|
||||
cronjob:
|
||||
suspend: &CronJobSuspended true
|
||||
schedule: &CronJobSchedule "0 3 * * *"
|
||||
concurrencyPolicy: &CronJobConcurrencyPolicy "Test"
|
||||
failedJobsHistory: &CronJobFailedJobsHistory 2
|
||||
successfulJobsHistory: &CronJobSuccessfulJobsHistory 3
|
||||
ttlSecondsAfterFinished: &ttlSecondsAfterFinished 3600
|
||||
parallelism: &CronJobParallelism 3
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: CronJob
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.suspend
|
||||
value: *CronJobSuspended
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.schedule
|
||||
value: *CronJobSchedule
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.concurrencyPolicy
|
||||
value: *CronJobConcurrencyPolicy
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.successfulJobsHistoryLimit
|
||||
value: *CronJobSuccessfulJobsHistory
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.failedJobsHistoryLimit
|
||||
value: *CronJobFailedJobsHistory
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.jobTemplate.spec.ttlSecondsAfterFinished
|
||||
value: *ttlSecondsAfterFinished
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.jobTemplate.spec.template.spec.restartPolicy
|
||||
value: OnFailure
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.jobTemplate.spec.parallelism
|
||||
value: *CronJobParallelism
|
|
@ -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
|
|
@ -0,0 +1,130 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: controller revisionHistoryLimit
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
# Deployment
|
||||
- it: default should pass for Deployment
|
||||
set:
|
||||
controllers.main.type: deployment
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.revisionHistoryLimit
|
||||
value: 3
|
||||
|
||||
- it: custom revisionHistoryLimit should pass for Deployment
|
||||
set:
|
||||
controllers.main:
|
||||
type: deployment
|
||||
revisionHistoryLimit: 8
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.revisionHistoryLimit
|
||||
value: 8
|
||||
|
||||
- it: explicit revisionHistoryLimit 0 should pass for Deployment
|
||||
set:
|
||||
controllers.main:
|
||||
type: deployment
|
||||
revisionHistoryLimit: 0
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.revisionHistoryLimit
|
||||
value: 0
|
||||
|
||||
# StatefulSet
|
||||
- it: default should pass for StatefulSet
|
||||
set:
|
||||
controllers.main.type: statefulset
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: StatefulSet
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.revisionHistoryLimit
|
||||
value: 3
|
||||
|
||||
- it: custom revisionHistoryLimit should pass for StatefulSet
|
||||
set:
|
||||
controllers.main:
|
||||
type: statefulset
|
||||
revisionHistoryLimit: 8
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: StatefulSet
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.revisionHistoryLimit
|
||||
value: 8
|
||||
|
||||
- it: explicit revisionHistoryLimit 0 should pass for StatefulSet
|
||||
set:
|
||||
controllers.main:
|
||||
type: statefulset
|
||||
revisionHistoryLimit: 0
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: StatefulSet
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.revisionHistoryLimit
|
||||
value: 0
|
||||
|
||||
# DaemonSet
|
||||
- it: default should pass for DaemonSet
|
||||
set:
|
||||
controllers.main.type: daemonset
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: DaemonSet
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.revisionHistoryLimit
|
||||
value: 3
|
||||
|
||||
- it: custom revisionHistoryLimit should pass for DaemonSet
|
||||
set:
|
||||
controllers.main:
|
||||
type: daemonset
|
||||
revisionHistoryLimit: 8
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: DaemonSet
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.revisionHistoryLimit
|
||||
value: 8
|
||||
|
||||
- it: explicit revisionHistoryLimit 0 should pass for DaemonSet
|
||||
set:
|
||||
controllers.main:
|
||||
type: daemonset
|
||||
revisionHistoryLimit: 0
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: DaemonSet
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.revisionHistoryLimit
|
||||
value: 0
|
|
@ -0,0 +1,65 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: job configuration
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default job configuration should pass
|
||||
set:
|
||||
controllers:
|
||||
main:
|
||||
type: job
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: Job
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.suspend
|
||||
value: false
|
||||
- documentIndex: *ControllerDoc
|
||||
notExists:
|
||||
path: spec.ttlSecondsAfterFinished
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.template.spec.restartPolicy
|
||||
value: Never
|
||||
|
||||
- it: custom job configuration should pass
|
||||
set:
|
||||
controllers:
|
||||
main:
|
||||
type: job
|
||||
pod:
|
||||
restartPolicy: OnFailure
|
||||
job:
|
||||
suspend: &JobSuspended true
|
||||
ttlSecondsAfterFinished: &ttlSecondsAfterFinished 3600
|
||||
backoffLimit: 3
|
||||
parallelism: &JobParallelism 3
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: Job
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.suspend
|
||||
value: *JobSuspended
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.ttlSecondsAfterFinished
|
||||
value: *ttlSecondsAfterFinished
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.template.spec.restartPolicy
|
||||
value: OnFailure
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.backoffLimit
|
||||
value: 3
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.parallelism
|
||||
value: *JobParallelism
|
|
@ -0,0 +1,123 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: controller metadata cronjob
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
set:
|
||||
controllers.main.cronjob.schedule: "*/20 * * * *"
|
||||
|
||||
tests:
|
||||
- it: default metadata should pass
|
||||
set:
|
||||
controllers.main.type: cronjob
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: CronJob
|
||||
- documentIndex: *ControllerDoc
|
||||
notExists:
|
||||
path: metadata.annotations
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/component: main
|
||||
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
|
||||
|
||||
- it: custom metadata should pass
|
||||
set:
|
||||
controllers:
|
||||
main:
|
||||
type: cronjob
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: CronJob
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
test_annotation: test
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/component: main
|
||||
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
|
||||
test_label: test
|
||||
|
||||
- it: custom metadata with global metadata should pass
|
||||
set:
|
||||
global:
|
||||
labels:
|
||||
global_label: test
|
||||
annotations:
|
||||
global_annotation: test
|
||||
controllers:
|
||||
main:
|
||||
type: cronjob
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: CronJob
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
global_annotation: test
|
||||
test_annotation: test
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/component: main
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
global_label: test
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
test_label: test
|
||||
|
||||
- it: jobTemplate metadata should pass
|
||||
set:
|
||||
controllers:
|
||||
main:
|
||||
type: cronjob
|
||||
pod:
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: CronJob
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.jobTemplate.spec.template.metadata.annotations
|
||||
value:
|
||||
test_annotation: test
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.jobTemplate.spec.template.metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/component: main
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
test_label: test
|
|
@ -0,0 +1,92 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: controller metadata daemonset
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default metadata should pass
|
||||
set:
|
||||
controllers.main.type: daemonset
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: DaemonSet
|
||||
- documentIndex: *ControllerDoc
|
||||
notExists:
|
||||
path: metadata.annotations
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/component: main
|
||||
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
|
||||
|
||||
- it: custom metadata should pass
|
||||
set:
|
||||
controllers:
|
||||
main:
|
||||
type: daemonset
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: DaemonSet
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
test_annotation: test
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/component: main
|
||||
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
|
||||
test_label: test
|
||||
|
||||
- it: custom metadata with global metadata should pass
|
||||
set:
|
||||
global:
|
||||
labels:
|
||||
global_label: test
|
||||
annotations:
|
||||
global_annotation: test
|
||||
controllers:
|
||||
main:
|
||||
type: daemonset
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: DaemonSet
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
global_annotation: test
|
||||
test_annotation: test
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/component: main
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
global_label: test
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
test_label: test
|
|
@ -0,0 +1,92 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: controller metadata deployment
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default metadata should pass
|
||||
set:
|
||||
controllers.main.type: deployment
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *ControllerDoc
|
||||
notExists:
|
||||
path: metadata.annotations
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/component: main
|
||||
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
|
||||
|
||||
- it: custom metadata should pass
|
||||
set:
|
||||
controllers:
|
||||
main:
|
||||
type: deployment
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
test_annotation: test
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/component: main
|
||||
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
|
||||
test_label: test
|
||||
|
||||
- it: custom metadata with global metadata should pass
|
||||
set:
|
||||
global:
|
||||
labels:
|
||||
global_label: test
|
||||
annotations:
|
||||
global_annotation: test
|
||||
controllers:
|
||||
main:
|
||||
type: deployment
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
global_annotation: test
|
||||
test_annotation: test
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/component: main
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
global_label: test
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
test_label: test
|
|
@ -0,0 +1,120 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: controller metadata job
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default metadata should pass
|
||||
set:
|
||||
controllers.main.type: job
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: Job
|
||||
- documentIndex: *ControllerDoc
|
||||
notExists:
|
||||
path: metadata.annotations
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/component: main
|
||||
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
|
||||
|
||||
- it: custom metadata should pass
|
||||
set:
|
||||
controllers:
|
||||
main:
|
||||
type: job
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: Job
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
test_annotation: test
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/component: main
|
||||
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
|
||||
test_label: test
|
||||
|
||||
- it: custom metadata with global metadata should pass
|
||||
set:
|
||||
global:
|
||||
labels:
|
||||
global_label: test
|
||||
annotations:
|
||||
global_annotation: test
|
||||
controllers:
|
||||
main:
|
||||
type: job
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: Job
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
global_annotation: test
|
||||
test_annotation: test
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/component: main
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
global_label: test
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
test_label: test
|
||||
|
||||
- it: jobTemplate metadata should pass
|
||||
set:
|
||||
controllers:
|
||||
main:
|
||||
type: job
|
||||
pod:
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: Job
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.template.metadata.annotations
|
||||
value:
|
||||
test_annotation: test
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.template.metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/component: main
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
test_label: test
|
|
@ -0,0 +1,92 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: controller metadata statefulset
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default metadata should pass
|
||||
set:
|
||||
controllers.main.type: statefulset
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: StatefulSet
|
||||
- documentIndex: *ControllerDoc
|
||||
notExists:
|
||||
path: metadata.annotations
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/component: main
|
||||
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
|
||||
|
||||
- it: custom metadata should pass
|
||||
set:
|
||||
controllers:
|
||||
main:
|
||||
type: statefulset
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: StatefulSet
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
test_annotation: test
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/component: main
|
||||
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
|
||||
test_label: test
|
||||
|
||||
- it: custom metadata with global metadata should pass
|
||||
set:
|
||||
global:
|
||||
labels:
|
||||
global_label: test
|
||||
annotations:
|
||||
global_annotation: test
|
||||
controllers:
|
||||
main:
|
||||
type: statefulset
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: StatefulSet
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
global_annotation: test
|
||||
test_annotation: test
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/component: main
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
global_label: test
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
test_label: test
|
|
@ -0,0 +1,138 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: controller types
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default should pass
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
- documentIndex: *deploymentDoc
|
||||
equal:
|
||||
path: metadata.labels['app.kubernetes.io/component']
|
||||
value: main
|
||||
|
||||
- it: additional controllers should pass
|
||||
set:
|
||||
controllers:
|
||||
second:
|
||||
containers:
|
||||
main:
|
||||
image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
tag: 31
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &firstDeploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *firstDeploymentDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-main
|
||||
- documentIndex: *firstDeploymentDoc
|
||||
equal:
|
||||
path: metadata.labels['app.kubernetes.io/component']
|
||||
value: main
|
||||
- documentIndex: &secondDeploymentDoc 1
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *secondDeploymentDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-second
|
||||
- documentIndex: *secondDeploymentDoc
|
||||
equal:
|
||||
path: metadata.labels['app.kubernetes.io/component']
|
||||
value: second
|
||||
|
||||
- it: additional controllers with nameOverride should pass
|
||||
set:
|
||||
controllers:
|
||||
main:
|
||||
nameOverride: "{{ .Release.Name }}"
|
||||
second:
|
||||
nameOverride: testOverride
|
||||
containers:
|
||||
main:
|
||||
image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
tag: 31
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &firstDeploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *firstDeploymentDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
- documentIndex: *firstDeploymentDoc
|
||||
equal:
|
||||
path: metadata.labels['app.kubernetes.io/component']
|
||||
value: main
|
||||
- documentIndex: &secondDeploymentDoc 1
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *secondDeploymentDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-testOverride
|
||||
- documentIndex: *secondDeploymentDoc
|
||||
equal:
|
||||
path: metadata.labels['app.kubernetes.io/component']
|
||||
value: second
|
||||
|
||||
- it: daemonset should pass
|
||||
set:
|
||||
controllers.main.type: daemonset
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: DaemonSet
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
|
||||
- it: statefulset should pass
|
||||
set:
|
||||
controllers.main.type: statefulset
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: StatefulSet
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
|
||||
- it: cronjob should pass
|
||||
set:
|
||||
controllers.main.type: cronjob
|
||||
controllers.main.cronjob.schedule: "*/20 * * * *"
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: CronJob
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
|
||||
- it: disabled should pass
|
||||
set:
|
||||
controllers.main.enabled: false
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
|
@ -0,0 +1,115 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: ingress metadata
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/ingress_main_default_hosts.yaml
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default metadata should pass
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
notExists:
|
||||
path: metadata.annotations
|
||||
- documentIndex: *IngressDocument
|
||||
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
|
||||
|
||||
- it: custom metadata should pass
|
||||
set:
|
||||
ingress.main:
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
test_annotation: test
|
||||
- documentIndex: *IngressDocument
|
||||
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
|
||||
test_label: test
|
||||
|
||||
- it: custom metadata with global metadata should pass
|
||||
set:
|
||||
global:
|
||||
labels:
|
||||
global_label: test
|
||||
annotations:
|
||||
global_annotation: test
|
||||
ingress.main:
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
global_annotation: test
|
||||
test_annotation: test
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
global_label: test
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
test_label: test
|
||||
|
||||
|
||||
- it: custom metadata with templates should pass
|
||||
set:
|
||||
ingress.main:
|
||||
annotations:
|
||||
template_annotation1: "{{ .Release.Name | lower }}"
|
||||
template_annotation2: "{{ .Chart.Name | lower }}"
|
||||
labels:
|
||||
template_label1: "{{ .Release.Name | lower }}"
|
||||
template_label2: "{{ .Chart.Name | lower }}"
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: metadata.annotations["template_annotation1"]
|
||||
value: release-name
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: metadata.annotations["template_annotation2"]
|
||||
value: common-test
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: metadata.labels["template_label1"]
|
||||
value: release-name
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: metadata.labels["template_label2"]
|
||||
value: common-test
|
|
@ -0,0 +1,113 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: ingress presence
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default should pass
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- documentIndex: 0
|
||||
not: true
|
||||
isKind:
|
||||
of: Ingress
|
||||
|
||||
- it: explicitly disabled should pass
|
||||
values:
|
||||
- ../_values/ingress_main_default_hosts.yaml
|
||||
set:
|
||||
ingress.main.enabled: false
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- documentIndex: 0
|
||||
not: true
|
||||
isKind:
|
||||
of: Ingress
|
||||
|
||||
- it: explicitly enabled should pass
|
||||
values:
|
||||
- ../_values/ingress_main_default_hosts.yaml
|
||||
set:
|
||||
ingress.main.enabled: true
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: 0
|
||||
not: true
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
|
||||
- it: multiple ingress should pass
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
- ../_values/ingress_main_default_hosts.yaml
|
||||
set:
|
||||
ingress.test:
|
||||
hosts:
|
||||
- host: "chart-example.local"
|
||||
paths:
|
||||
- path: /
|
||||
service:
|
||||
identifier: main
|
||||
port: http
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 4
|
||||
- documentIndex: 0
|
||||
not: true
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: 1
|
||||
not: true
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: &FirstIngressDocument 2
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *FirstIngressDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-main
|
||||
- documentIndex: &SecondIngressDocument 3
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *SecondIngressDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-test
|
||||
|
||||
- it: multiple ingress with explicit disabled should pass
|
||||
values:
|
||||
- ../_values/ingress_main_default_hosts.yaml
|
||||
set:
|
||||
ingress.test:
|
||||
enabled: false
|
||||
hosts:
|
||||
- host: "chart-example.local"
|
||||
paths:
|
||||
- path: /
|
||||
service:
|
||||
identifier: main
|
||||
port: http
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: 0
|
||||
not: true
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: &FirstIngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *FirstIngressDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
|
@ -0,0 +1,143 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: ingress service reference
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/ingress_main_default_hosts.yaml
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default should pass
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
port: &httpPort 8081
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 2
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[0].http.paths[0].backend
|
||||
value:
|
||||
service:
|
||||
name: RELEASE-NAME
|
||||
port:
|
||||
number: *httpPort
|
||||
|
||||
- it: custom service reference should pass
|
||||
set:
|
||||
ingress.main:
|
||||
hosts:
|
||||
- host: chart-test.local
|
||||
paths:
|
||||
- path: /
|
||||
service:
|
||||
name: pathService
|
||||
port: 1234
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[0].http.paths[0].backend
|
||||
value:
|
||||
service:
|
||||
name: pathService
|
||||
port:
|
||||
number: 1234
|
||||
|
||||
- it: custom service reference with template should pass
|
||||
set:
|
||||
ingress.main:
|
||||
hosts:
|
||||
- host: chart-test.local
|
||||
paths:
|
||||
- path: /
|
||||
service:
|
||||
name: "{{ .Release.Name }}"
|
||||
port: 1234
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[0].http.paths[0].backend
|
||||
value:
|
||||
service:
|
||||
name: RELEASE-NAME
|
||||
port:
|
||||
number: 1234
|
||||
|
||||
- it: multiple hosts with port name references should pass
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
port: &httpPort 8081
|
||||
http2:
|
||||
enabled: true
|
||||
port: &http2Port 1880
|
||||
ingress:
|
||||
main:
|
||||
className: "nginx"
|
||||
hosts:
|
||||
- host: http.chart-test.local
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
service:
|
||||
identifier: main
|
||||
port: http
|
||||
- host: http2.chart-test.local
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
service:
|
||||
identifier: main
|
||||
port: http2
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 2
|
||||
isKind:
|
||||
of: Ingress
|
||||
# First Ingress host
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[0].host
|
||||
value: http.chart-test.local
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[0].http.paths[0].path
|
||||
value: "/"
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[0].http.paths[0].backend.service.name
|
||||
value: "RELEASE-NAME"
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[0].http.paths[0].backend.service.port.number
|
||||
value: *httpPort
|
||||
# Second Ingress host
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[1].host
|
||||
value: http2.chart-test.local
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[1].http.paths[0].path
|
||||
value: "/"
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[1].http.paths[0].backend.service.name
|
||||
value: "RELEASE-NAME"
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[1].http.paths[0].backend.service.port.number
|
||||
value: *http2Port
|
|
@ -0,0 +1,90 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: ingress tls
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/ingress_main_default_hosts.yaml
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default should pass
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
notExists:
|
||||
path: spec.tls
|
||||
|
||||
- it: tls enabled should pass
|
||||
set:
|
||||
ingress.main:
|
||||
tls:
|
||||
- secretName: test
|
||||
hosts:
|
||||
- hostname
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.tls[0]
|
||||
value:
|
||||
secretName: test
|
||||
hosts:
|
||||
- hostname
|
||||
|
||||
- it: tls enabled without secret should pass
|
||||
set:
|
||||
ingress.main:
|
||||
tls:
|
||||
- hosts:
|
||||
- hostname
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.tls[0]
|
||||
value:
|
||||
hosts:
|
||||
- hostname
|
||||
|
||||
- it: tls enabled with secret template should pass
|
||||
set:
|
||||
ingress.main:
|
||||
tls:
|
||||
- secretName: "{{ .Release.Name }}-secret"
|
||||
hosts:
|
||||
- hostname
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.tls[0]
|
||||
value:
|
||||
secretName: RELEASE-NAME-secret
|
||||
hosts:
|
||||
- hostname
|
||||
|
||||
- it: tls enabled with secret template evaluate empty should pass
|
||||
set:
|
||||
ingress.main:
|
||||
tls:
|
||||
- secretName: '{{ "" }}'
|
||||
hosts:
|
||||
- hostname
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.tls[0]
|
||||
value:
|
||||
hosts:
|
||||
- hostname
|
|
@ -0,0 +1,132 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: ingress values
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/ingress_main_default_hosts.yaml
|
||||
- ../_values/service_main_default.yaml
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default should pass
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 2
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[0].host
|
||||
value: chart-example.local
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[0].http.paths[0].path
|
||||
value: "/"
|
||||
|
||||
- it: nameOverride should pass
|
||||
set:
|
||||
ingress.main:
|
||||
nameOverride: test
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 2
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-test
|
||||
|
||||
- it: nameOverride with template should pass
|
||||
set:
|
||||
ingress.main:
|
||||
nameOverride: "{{ .Release.Name }}"
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 2
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
|
||||
- it: custom host and path should pass
|
||||
set:
|
||||
ingress.main:
|
||||
hosts:
|
||||
- host: chart-test.local
|
||||
paths:
|
||||
- path: /test
|
||||
service:
|
||||
identifier: main
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 2
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[0].host
|
||||
value: chart-test.local
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[0].http.paths[0].path
|
||||
value: "/test"
|
||||
|
||||
- it: host with template should pass
|
||||
set:
|
||||
ingress.main:
|
||||
hosts:
|
||||
- host: "{{ .Release.Name }}.hostname"
|
||||
paths:
|
||||
- path: /
|
||||
service:
|
||||
identifier: main
|
||||
port: http
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 2
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[0].host
|
||||
value: RELEASE-NAME.hostname
|
||||
|
||||
- it: path with template should pass
|
||||
set:
|
||||
ingress.main:
|
||||
hosts:
|
||||
- host: chart-test.local
|
||||
paths:
|
||||
- path: "/{{ .Release.Name }}.path"
|
||||
service:
|
||||
identifier: main
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 2
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[0].http.paths[0].path
|
||||
value: "/RELEASE-NAME.path"
|
||||
|
||||
- it: with defaultBackend should pass
|
||||
set:
|
||||
ingress.main:
|
||||
defaultBackend:
|
||||
resource:
|
||||
apiGroup: k8s.example.com
|
||||
kind: StorageBucket
|
||||
name: static-assets
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 2
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.defaultBackend
|
||||
value:
|
||||
resource:
|
||||
apiGroup: k8s.example.com
|
||||
kind: StorageBucket
|
||||
name: static-assets
|
||||
- documentIndex: *IngressDocument
|
||||
notExists:
|
||||
path: spec.rules
|
|
@ -0,0 +1,29 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: nameOverride tests
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default name is set to release name
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
|
||||
- it: global.nameOverride can be set
|
||||
set:
|
||||
global.nameOverride: custom-name
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-custom-name
|
|
@ -0,0 +1,94 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: networkPolicy metadata
|
||||
|
||||
set:
|
||||
networkpolicies.main:
|
||||
controller: main
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
rules: {}
|
||||
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default metadata should pass
|
||||
asserts:
|
||||
- documentIndex: &NetworkPolicyDocument 1
|
||||
isKind:
|
||||
of: NetworkPolicy
|
||||
- documentIndex: *NetworkPolicyDocument
|
||||
notExists:
|
||||
path: metadata.annotations
|
||||
- documentIndex: *NetworkPolicyDocument
|
||||
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
|
||||
|
||||
- it: custom metadata should pass
|
||||
set:
|
||||
networkpolicies:
|
||||
main:
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- documentIndex: &NetworkPolicyDocument 1
|
||||
isKind:
|
||||
of: NetworkPolicy
|
||||
- documentIndex: *NetworkPolicyDocument
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
test_annotation: test
|
||||
- documentIndex: *NetworkPolicyDocument
|
||||
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
|
||||
test_label: test
|
||||
|
||||
- it: custom metadata with global metadata should pass
|
||||
set:
|
||||
global:
|
||||
labels:
|
||||
global_label: test
|
||||
annotations:
|
||||
global_annotation: test
|
||||
networkpolicies:
|
||||
main:
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- documentIndex: &NetworkPolicyDocument 1
|
||||
isKind:
|
||||
of: NetworkPolicy
|
||||
- documentIndex: *NetworkPolicyDocument
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
global_annotation: test
|
||||
test_annotation: test
|
||||
- documentIndex: *NetworkPolicyDocument
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
global_label: test
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
test_label: test
|
|
@ -0,0 +1,85 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: networkPolicy names
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default should pass
|
||||
set:
|
||||
networkpolicies:
|
||||
main:
|
||||
controller: main
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
rules: {}
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &NetworkPolicyDocument 1
|
||||
isKind:
|
||||
of: NetworkPolicy
|
||||
- documentIndex: *NetworkPolicyDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
|
||||
- it: custom name suffix should pass
|
||||
set:
|
||||
networkpolicies:
|
||||
main:
|
||||
controller: main
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
rules: {}
|
||||
nameOverride: block-ingress
|
||||
asserts:
|
||||
- documentIndex: &NetworkPolicyDocument 1
|
||||
isKind:
|
||||
of: NetworkPolicy
|
||||
- documentIndex: *NetworkPolicyDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-block-ingress
|
||||
|
||||
- it: multiple networkpolicies can be enabled
|
||||
set:
|
||||
networkpolicies:
|
||||
primary:
|
||||
controller: main
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
rules: {}
|
||||
secondary:
|
||||
controller: main
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
rules: {}
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 3
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: &firstNetworkPolicyDocument 1
|
||||
isKind:
|
||||
of: NetworkPolicy
|
||||
- documentIndex: *firstNetworkPolicyDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-primary
|
||||
- documentIndex: 2
|
||||
isKind:
|
||||
of: NetworkPolicy
|
||||
- documentIndex: &secondNetworkPolicyDocument 2
|
||||
isKind:
|
||||
of: NetworkPolicy
|
||||
- documentIndex: *secondNetworkPolicyDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-secondary
|
|
@ -0,0 +1,40 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: NetworkPolicy validations
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: networkpolicy requires either controller reference or podSelector
|
||||
set:
|
||||
networkpolicies:
|
||||
main:
|
||||
controller: ""
|
||||
rules: {}
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: "controller reference or podSelector is required for NetworkPolicy. (NetworkPolicy main)"
|
||||
|
||||
- it: policyTypes is required
|
||||
set:
|
||||
networkpolicies:
|
||||
main:
|
||||
controller: main
|
||||
policyTypes: []
|
||||
rules: {}
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: "policyTypes is required for NetworkPolicy. (NetworkPolicy main)"
|
||||
|
||||
- it: policyTypes values check
|
||||
set:
|
||||
networkpolicies:
|
||||
main:
|
||||
controller: main
|
||||
policyTypes:
|
||||
- test
|
||||
rules: {}
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: "Not a valid policyType for NetworkPolicy. (NetworkPolicy main, value test)"
|
|
@ -0,0 +1,103 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: NetworkPolicy values
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: main networkpolicy is disabled by default
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- documentIndex: 0
|
||||
not: true
|
||||
isKind:
|
||||
of: NetworkPolicy
|
||||
|
||||
- it: main networkpolicy can be enabled
|
||||
set:
|
||||
networkpolicies.main:
|
||||
controller: main
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
rules: {}
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 1
|
||||
isKind:
|
||||
of: NetworkPolicy
|
||||
|
||||
- it: networkpolicy targets the correct controller
|
||||
set:
|
||||
networkpolicies:
|
||||
main:
|
||||
controller: main
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
rules: {}
|
||||
asserts:
|
||||
- documentIndex: &NetworkPolicyDocument 1
|
||||
isKind:
|
||||
of: NetworkPolicy
|
||||
- documentIndex: *NetworkPolicyDocument
|
||||
equal:
|
||||
path: spec.podSelector
|
||||
value:
|
||||
matchLabels:
|
||||
app.kubernetes.io/component: main
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
|
||||
- it: networkpolicy targets supports custom podSelector
|
||||
set:
|
||||
networkpolicies:
|
||||
main:
|
||||
controller: main
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
podSelector: {}
|
||||
rules: {}
|
||||
asserts:
|
||||
- documentIndex: &NetworkPolicyDocument 1
|
||||
isKind:
|
||||
of: NetworkPolicy
|
||||
- documentIndex: *NetworkPolicyDocument
|
||||
equal:
|
||||
path: spec.podSelector
|
||||
value: {}
|
||||
|
||||
- it: networkpolicy rules are passed through
|
||||
set:
|
||||
networkpolicies:
|
||||
main:
|
||||
controller: main
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
rules:
|
||||
ingress:
|
||||
- {}
|
||||
egress:
|
||||
- {}
|
||||
asserts:
|
||||
- documentIndex: &NetworkPolicyDocument 1
|
||||
isKind:
|
||||
of: NetworkPolicy
|
||||
- documentIndex: *NetworkPolicyDocument
|
||||
equal:
|
||||
path: spec.ingress
|
||||
value:
|
||||
- {}
|
||||
- documentIndex: *NetworkPolicyDocument
|
||||
equal:
|
||||
path: spec.egress
|
||||
value:
|
||||
- {}
|
|
@ -0,0 +1,80 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: persistence claimnames
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default should pass
|
||||
set:
|
||||
persistence:
|
||||
config:
|
||||
accessMode: ReadWriteOnce
|
||||
size: 1Gi
|
||||
asserts:
|
||||
- documentIndex: 1
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 1
|
||||
equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: config
|
||||
persistentVolumeClaim:
|
||||
claimName: RELEASE-NAME-config
|
||||
|
||||
- it: with existingClaim should pass
|
||||
set:
|
||||
persistence:
|
||||
existingClaim:
|
||||
existingClaim: myClaim
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: existingClaim
|
||||
persistentVolumeClaim:
|
||||
claimName: myClaim
|
||||
|
||||
- it: disabled suffix should pass
|
||||
set:
|
||||
persistence:
|
||||
claimWithoutSuffix:
|
||||
nameOverride: "-"
|
||||
accessMode: ReadWriteMany
|
||||
size: 1G
|
||||
asserts:
|
||||
- documentIndex: 1
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 1
|
||||
equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: claimWithoutSuffix
|
||||
persistentVolumeClaim:
|
||||
claimName: RELEASE-NAME
|
||||
|
||||
- it: custom suffix should pass
|
||||
set:
|
||||
persistence:
|
||||
claimWithNameOverride:
|
||||
nameOverride: suffix
|
||||
accessMode: ReadWriteMany
|
||||
size: 1G
|
||||
asserts:
|
||||
- documentIndex: 1
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 1
|
||||
equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: claimWithNameOverride
|
||||
persistentVolumeClaim:
|
||||
claimName: RELEASE-NAME-suffix
|
|
@ -0,0 +1,78 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: persistence configmap
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: configmap persistence type should pass
|
||||
set:
|
||||
persistence:
|
||||
configmap:
|
||||
type: configMap
|
||||
name: mySettings
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: configmap
|
||||
configMap:
|
||||
name: mySettings
|
||||
|
||||
- it: configmap persistence type with name template should pass
|
||||
set:
|
||||
persistence:
|
||||
configmap:
|
||||
type: configMap
|
||||
name: '{{ include "bjw-s.common.lib.chart.names.fullname" $ }}-config'
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: configmap
|
||||
configMap:
|
||||
name: RELEASE-NAME-config
|
||||
|
||||
- it: configmap persistence type with identifier reference should pass
|
||||
set:
|
||||
configMaps:
|
||||
mySettings:
|
||||
data:
|
||||
test: testvalue
|
||||
persistence:
|
||||
configmap:
|
||||
type: configMap
|
||||
identifier: mySettings
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: 1
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 1
|
||||
equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: configmap
|
||||
configMap:
|
||||
name: RELEASE-NAME-mySettings
|
||||
|
||||
- it: configmap persistence type with invalid identifier reference should fail
|
||||
set:
|
||||
persistence:
|
||||
configmap:
|
||||
type: configMap
|
||||
identifier: doesNotExist
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: "No configmap found with this identifier. (persistence item 'configmap', identifier 'doesNotExist')"
|
|
@ -0,0 +1,34 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: persistence custom
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: custom persistence type should pass
|
||||
set:
|
||||
persistence:
|
||||
custom-mount:
|
||||
enabled: true
|
||||
type: custom
|
||||
volumeSpec:
|
||||
downwardAPI:
|
||||
items:
|
||||
- path: "labels"
|
||||
fieldRef:
|
||||
fieldPath: metadata.labels
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: custom-mount
|
||||
downwardAPI:
|
||||
items:
|
||||
- fieldRef:
|
||||
fieldPath: metadata.labels
|
||||
path: labels
|
|
@ -0,0 +1,64 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: persistence emptydir
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default emptyDir should pass
|
||||
set:
|
||||
persistence:
|
||||
config:
|
||||
enabled: true
|
||||
type: emptyDir
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: config
|
||||
emptyDir: {}
|
||||
|
||||
- it: emptyDir with medium should pass
|
||||
set:
|
||||
persistence:
|
||||
config:
|
||||
enabled: true
|
||||
type: emptyDir
|
||||
medium: memory
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: config
|
||||
emptyDir:
|
||||
medium: memory
|
||||
|
||||
- it: emptyDir with medium and sizeLimit should pass
|
||||
set:
|
||||
persistence:
|
||||
config:
|
||||
enabled: true
|
||||
type: emptyDir
|
||||
medium: memory
|
||||
sizeLimit: 1Gi
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: config
|
||||
emptyDir:
|
||||
medium: memory
|
||||
sizeLimit: 1Gi
|
|
@ -0,0 +1,47 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: persistence hostpath
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: hostPath should pass
|
||||
set:
|
||||
persistence:
|
||||
hostpathmounts-data:
|
||||
enabled: true
|
||||
type: hostPath
|
||||
hostPath: "/tmp1"
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: hostpathmounts-data
|
||||
hostPath:
|
||||
path: /tmp1
|
||||
|
||||
- it: hostPath with type should pass
|
||||
set:
|
||||
persistence:
|
||||
hostpathmounts-with-type:
|
||||
enabled: true
|
||||
type: hostPath
|
||||
hostPath: "/tmp2"
|
||||
hostPathType: "Directory"
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: hostpathmounts-with-type
|
||||
hostPath:
|
||||
path: /tmp2
|
||||
type: Directory
|
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: persistence nfs
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: nfs persistence type should pass
|
||||
set:
|
||||
persistence:
|
||||
nfs:
|
||||
enabled: true
|
||||
type: nfs
|
||||
server: 10.10.0.8
|
||||
path: /tank/nas/library
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: nfs
|
||||
nfs:
|
||||
path: /tank/nas/library
|
||||
server: 10.10.0.8
|
|
@ -0,0 +1,77 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: persistence secret
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: secret persistence type should pass
|
||||
set:
|
||||
persistence:
|
||||
secret:
|
||||
enabled: true
|
||||
type: secret
|
||||
name: mySettings
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: secret
|
||||
secret:
|
||||
secretName: mySettings
|
||||
|
||||
- it: secret persistence type with name template should pass
|
||||
set:
|
||||
persistence:
|
||||
secret:
|
||||
enabled: true
|
||||
type: secret
|
||||
name: "{{ .Release.Name }}-config"
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: secret
|
||||
secret:
|
||||
secretName: RELEASE-NAME-config
|
||||
|
||||
- it: secret persistence type with identifier reference should pass
|
||||
set:
|
||||
secrets:
|
||||
mySettings:
|
||||
stringData:
|
||||
test: testvalue
|
||||
persistence:
|
||||
secret:
|
||||
type: secret
|
||||
identifier: mySettings
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: secret
|
||||
secret:
|
||||
secretName: RELEASE-NAME-mySettings
|
||||
|
||||
- it: secret persistence type with invalid identifier reference should fail
|
||||
set:
|
||||
persistence:
|
||||
secret:
|
||||
type: secret
|
||||
identifier: doesNotExist
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: "No secret found with this identifier. (persistence item 'secret', identifier 'doesNotExist')"
|
|
@ -0,0 +1,92 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: persistence volumeclaimtemplates
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default should pass
|
||||
set:
|
||||
controllers.main:
|
||||
type: statefulset
|
||||
asserts:
|
||||
- documentIndex: &StatefulSetDoc 0
|
||||
isKind:
|
||||
of: StatefulSet
|
||||
- documentIndex: *StatefulSetDoc
|
||||
notExists:
|
||||
path: spec.volumeClaimTemplates
|
||||
|
||||
- it: volumeClaimTemplates should pass
|
||||
set:
|
||||
controllers.main:
|
||||
type: statefulset
|
||||
statefulset:
|
||||
volumeClaimTemplates:
|
||||
- name: "storage"
|
||||
size: "10Gi"
|
||||
accessMode: "ReadWriteOnce"
|
||||
asserts:
|
||||
- documentIndex: &StatefulSetDoc 0
|
||||
isKind:
|
||||
of: StatefulSet
|
||||
- documentIndex: *StatefulSetDoc
|
||||
equal:
|
||||
path: spec.volumeClaimTemplates[0]
|
||||
value:
|
||||
metadata:
|
||||
name: storage
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
|
||||
- it: volumeClaimTemplates with dataSource should pass
|
||||
set:
|
||||
controllers.main:
|
||||
type: statefulset
|
||||
statefulset:
|
||||
volumeClaimTemplates:
|
||||
- name: "storage"
|
||||
size: "10Gi"
|
||||
accessMode: "ReadWriteOnce"
|
||||
dataSource:
|
||||
apiGroup: snapshot.storage.k8s.io
|
||||
kind: VolumeSnapshot
|
||||
name: MySnapshot
|
||||
asserts:
|
||||
- documentIndex: &StatefulSetDoc 0
|
||||
isKind:
|
||||
of: StatefulSet
|
||||
- documentIndex: *StatefulSetDoc
|
||||
equal:
|
||||
path: spec.volumeClaimTemplates[0].spec.dataSource
|
||||
value:
|
||||
apiGroup: snapshot.storage.k8s.io
|
||||
kind: VolumeSnapshot
|
||||
name: MySnapshot
|
||||
|
||||
- it: volumeClaimTemplates with templated dataSource name should pass
|
||||
set:
|
||||
controllers.main:
|
||||
type: statefulset
|
||||
statefulset:
|
||||
volumeClaimTemplates:
|
||||
- name: "storage"
|
||||
size: "10Gi"
|
||||
accessMode: "ReadWriteOnce"
|
||||
dataSource:
|
||||
apiGroup: snapshot.storage.k8s.io
|
||||
kind: VolumeSnapshot
|
||||
name: "{{ .Release.Name }}-config"
|
||||
asserts:
|
||||
- documentIndex: &StatefulSetDoc 0
|
||||
isKind:
|
||||
of: StatefulSet
|
||||
- documentIndex: *StatefulSetDoc
|
||||
equal:
|
||||
path: spec.volumeClaimTemplates[0].spec.dataSource.name
|
||||
value: RELEASE-NAME-config
|
|
@ -0,0 +1,111 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: persistence volumes
|
||||
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.volumes
|
||||
|
||||
- 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.volumes
|
||||
value:
|
||||
- name: config
|
||||
persistentVolumeClaim:
|
||||
claimName: RELEASE-NAME-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:
|
||||
config:
|
||||
existingClaim: test
|
||||
advancedMounts:
|
||||
main:
|
||||
main:
|
||||
- path: /config
|
||||
readOnly: false
|
||||
data:
|
||||
type: configMap
|
||||
name: myConfigMap
|
||||
globalMounts:
|
||||
- path: /globalTest
|
||||
advancedMounts:
|
||||
main:
|
||||
main:
|
||||
- path: /data/config.yaml
|
||||
readOnly: false
|
||||
subPath: config.yaml
|
||||
second-container:
|
||||
- path: /appdata/config
|
||||
readOnly: true
|
||||
second:
|
||||
first-container:
|
||||
- path: /second-pod/config.yaml
|
||||
readOnly: false
|
||||
subPath: config.yaml
|
||||
no-mounts:
|
||||
existingClaim: test
|
||||
|
||||
asserts:
|
||||
- documentIndex: &FirstDeploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *FirstDeploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.volumes
|
||||
value:
|
||||
- name: config
|
||||
persistentVolumeClaim:
|
||||
claimName: test
|
||||
- configMap:
|
||||
name: myConfigMap
|
||||
name: data
|
||||
- name: no-mounts
|
||||
persistentVolumeClaim:
|
||||
claimName: test
|
||||
- documentIndex: &SecondDeploymentDoc 1
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *SecondDeploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.volumes
|
||||
value:
|
||||
- configMap:
|
||||
name: myConfigMap
|
||||
name: data
|
||||
- name: no-mounts
|
||||
persistentVolumeClaim:
|
||||
claimName: test
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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"
|
|
@ -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
|
|
@ -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
|
|
@ -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"
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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"
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -0,0 +1,112 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: pvc datasource
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
set:
|
||||
persistence.config:
|
||||
accessMode: ReadWriteOnce
|
||||
size: 1Gi
|
||||
|
||||
tests:
|
||||
- it: default should pass
|
||||
asserts:
|
||||
- documentIndex: &PersistentVolumeClaimDocument 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
notExists:
|
||||
path: spec.dataSource
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
notExists:
|
||||
path: spec.dataSourceRef
|
||||
|
||||
- it: with dataSource should pass
|
||||
set:
|
||||
persistence.config:
|
||||
dataSource:
|
||||
apiGroup: snapshot.storage.k8s.io
|
||||
kind: VolumeSnapshot
|
||||
name: MySnapshot
|
||||
asserts:
|
||||
- documentIndex: &PersistentVolumeClaimDocument 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
equal:
|
||||
path: spec.dataSource
|
||||
value:
|
||||
apiGroup: snapshot.storage.k8s.io
|
||||
kind: VolumeSnapshot
|
||||
name: MySnapshot
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
notExists:
|
||||
path: spec.dataSourceRef
|
||||
|
||||
- it: templated dataSource name should pass
|
||||
set:
|
||||
persistence.config:
|
||||
dataSource:
|
||||
apiGroup: snapshot.storage.k8s.io
|
||||
kind: VolumeSnapshot
|
||||
name: "{{ .Release.Name }}-config"
|
||||
asserts:
|
||||
- documentIndex: &PersistentVolumeClaimDocument 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
equal:
|
||||
path: spec.dataSource
|
||||
value:
|
||||
apiGroup: snapshot.storage.k8s.io
|
||||
kind: VolumeSnapshot
|
||||
name: RELEASE-NAME-config
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
notExists:
|
||||
path: spec.dataSourceRef
|
||||
|
||||
- it: with dataSourceRef should pass
|
||||
set:
|
||||
persistence.config:
|
||||
dataSourceRef:
|
||||
apiGroup: snapshot.storage.k8s.io
|
||||
kind: VolumeSnapshot
|
||||
name: MySnapshot
|
||||
asserts:
|
||||
- documentIndex: &PersistentVolumeClaimDocument 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
equal:
|
||||
path: spec.dataSourceRef
|
||||
value:
|
||||
apiGroup: snapshot.storage.k8s.io
|
||||
kind: VolumeSnapshot
|
||||
name: MySnapshot
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
notExists:
|
||||
path: spec.dataSource
|
||||
|
||||
- it: templated dataSourceRef name should pass
|
||||
set:
|
||||
persistence.config:
|
||||
dataSourceRef:
|
||||
apiGroup: snapshot.storage.k8s.io
|
||||
kind: VolumeSnapshot
|
||||
name: "{{ .Release.Name }}-config"
|
||||
asserts:
|
||||
- documentIndex: &PersistentVolumeClaimDocument 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
equal:
|
||||
path: spec.dataSourceRef
|
||||
value:
|
||||
apiGroup: snapshot.storage.k8s.io
|
||||
kind: VolumeSnapshot
|
||||
name: RELEASE-NAME-config
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
notExists:
|
||||
path: spec.dataSource
|
|
@ -0,0 +1,110 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: pvc metadata
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
set:
|
||||
persistence.config:
|
||||
accessMode: ReadWriteOnce
|
||||
size: 1Gi
|
||||
|
||||
tests:
|
||||
- it: default should pass
|
||||
asserts:
|
||||
- documentIndex: &PersistentVolumeClaimDocument 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
notExists:
|
||||
path: metadata.annotations
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
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
|
||||
|
||||
- it: retain enabled should pass
|
||||
set:
|
||||
persistence.config:
|
||||
retain: true
|
||||
asserts:
|
||||
- documentIndex: &PersistentVolumeClaimDocument 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
helm.sh/resource-policy: keep
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
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
|
||||
|
||||
- it: custom metadata should pass
|
||||
set:
|
||||
persistence.config:
|
||||
labels:
|
||||
test_label: test
|
||||
annotations:
|
||||
test_annotation: test
|
||||
asserts:
|
||||
- documentIndex: &PersistentVolumeClaimDocument 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
test_annotation: test
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
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
|
||||
test_label: test
|
||||
|
||||
- it: custom metadata with global metadata should pass
|
||||
set:
|
||||
global:
|
||||
labels:
|
||||
global_label: test
|
||||
annotations:
|
||||
global_annotation: test
|
||||
persistence.config:
|
||||
labels:
|
||||
test_label: test
|
||||
annotations:
|
||||
test_annotation: test
|
||||
asserts:
|
||||
- documentIndex: &PersistentVolumeClaimDocument 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
test_annotation: test
|
||||
global_annotation: test
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
global_label: test
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
test_label: test
|
|
@ -0,0 +1,67 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: pvc names
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
set:
|
||||
persistence.config:
|
||||
accessMode: ReadWriteOnce
|
||||
size: 1Gi
|
||||
|
||||
tests:
|
||||
- it: disabled should pass
|
||||
set:
|
||||
persistence.config.enabled: false
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- documentIndex: 0
|
||||
not: true
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
|
||||
- it: enabled should pass
|
||||
set:
|
||||
persistence.config.enabled: true
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &PersistentVolumeClaimDocument 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: 1
|
||||
not: true
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-config
|
||||
|
||||
- it: without suffix should pass
|
||||
set:
|
||||
persistence.config:
|
||||
nameOverride: "-"
|
||||
asserts:
|
||||
- documentIndex: &PersistentVolumeClaimDocument 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
|
||||
- it: with custom suffix should pass
|
||||
set:
|
||||
persistence.config:
|
||||
nameOverride: "custom"
|
||||
asserts:
|
||||
- documentIndex: &PersistentVolumeClaimDocument 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-custom
|
|
@ -0,0 +1,47 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: pvc storageclass
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
set:
|
||||
persistence.config:
|
||||
accessMode: ReadWriteOnce
|
||||
size: 1Gi
|
||||
|
||||
tests:
|
||||
- it: default should pass
|
||||
asserts:
|
||||
- documentIndex: &PersistentVolumeClaimDocument 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
notExists:
|
||||
path: spec.storageClassName
|
||||
|
||||
- it: custom should pass
|
||||
set:
|
||||
persistence.config:
|
||||
storageClass: custom
|
||||
asserts:
|
||||
- documentIndex: &PersistentVolumeClaimDocument 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
equal:
|
||||
path: spec.storageClassName
|
||||
value: custom
|
||||
|
||||
- it: empty should pass
|
||||
set:
|
||||
persistence.config:
|
||||
storageClass: "-"
|
||||
asserts:
|
||||
- documentIndex: &PersistentVolumeClaimDocument 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
equal:
|
||||
path: spec.storageClassName
|
||||
value: ""
|
|
@ -0,0 +1,56 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: pvc values
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default enabled should pass
|
||||
set:
|
||||
persistence.test:
|
||||
type: persistentVolumeClaim
|
||||
accessMode: ReadWriteOnce
|
||||
size: 1Gi
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &PersistentVolumeClaimDocument 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-test
|
||||
|
||||
- it: explicit enabled should pass
|
||||
set:
|
||||
persistence.test:
|
||||
enabled: true
|
||||
type: persistentVolumeClaim
|
||||
accessMode: ReadWriteOnce
|
||||
size: 1Gi
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &PersistentVolumeClaimDocument 0
|
||||
isKind:
|
||||
of: PersistentVolumeClaim
|
||||
- documentIndex: *PersistentVolumeClaimDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-test
|
||||
|
||||
- it: explicit disabled
|
||||
set:
|
||||
persistence.test:
|
||||
enabled: false
|
||||
type: persistentVolumeClaim
|
||||
accessMode: ReadWriteOnce
|
||||
size: 1Gi
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- documentIndex: &PersistentVolumeClaimDocument 0
|
||||
isKind:
|
||||
of: Deployment
|
|
@ -0,0 +1,82 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: rawResource metadata
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
set:
|
||||
rawResources:
|
||||
config:
|
||||
apiVersion: v1
|
||||
kind: Endpoint
|
||||
spec:
|
||||
test: test
|
||||
tests:
|
||||
- it: default metadata should be present
|
||||
documentSelector: &EndpointSelector
|
||||
path: $[?(@.kind == "Endpoint")].metadata.name
|
||||
value: RELEASE-NAME-config
|
||||
asserts:
|
||||
- notExists:
|
||||
path: metadata.annotations
|
||||
- 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
|
||||
|
||||
- it: custom metadata can be configured
|
||||
set:
|
||||
rawResources:
|
||||
config:
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
documentSelector: *EndpointSelector
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
test_annotation: test
|
||||
- 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
|
||||
test_label: test
|
||||
|
||||
- it: global metadata can be configured with local overrides
|
||||
set:
|
||||
global:
|
||||
labels:
|
||||
global_label: test
|
||||
annotations:
|
||||
global_annotation: test
|
||||
rawResources:
|
||||
config:
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
documentSelector: *EndpointSelector
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
global_annotation: test
|
||||
test_annotation: test
|
||||
- equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
global_label: test
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
test_label: test
|
|
@ -0,0 +1,70 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: rawResource values
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
set:
|
||||
rawResources:
|
||||
endpoint:
|
||||
apiVersion: v1
|
||||
kind: Endpoint
|
||||
spec:
|
||||
subsets:
|
||||
- addresses:
|
||||
- ip: 127.0.0.1
|
||||
ports:
|
||||
- name: "{{ .Release.Name }}"
|
||||
port: 443
|
||||
protocol: TCP
|
||||
tests:
|
||||
- it: raw resources can be configured
|
||||
documentSelector: &EndpointSelector
|
||||
path: $[?(@.kind == "Endpoint")].metadata.name
|
||||
value: RELEASE-NAME-endpoint
|
||||
asserts:
|
||||
- equal:
|
||||
path: subsets[0].addresses[0].ip
|
||||
value: 127.0.0.1
|
||||
|
||||
- it: nameOverride can be configured
|
||||
set:
|
||||
rawResources.endpoint:
|
||||
nameOverride: test
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Endpoint")].metadata.name
|
||||
value: RELEASE-NAME-test
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-test
|
||||
|
||||
- it: nameOverride with template should pass
|
||||
set:
|
||||
rawResources.endpoint:
|
||||
nameOverride: "{{ .Release.Name }}"
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Endpoint")].metadata.name
|
||||
value: RELEASE-NAME
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
|
||||
- it: spec can render Helm template
|
||||
set:
|
||||
rawResources.endpoint:
|
||||
spec:
|
||||
subsets:
|
||||
- addresses:
|
||||
- ip: 127.0.0.1
|
||||
ports:
|
||||
- name: "{{ .Release.Name }}"
|
||||
port: 443
|
||||
protocol: TCP
|
||||
documentSelector: *EndpointSelector
|
||||
asserts:
|
||||
- equal:
|
||||
path: subsets[0].ports[0].name
|
||||
value: RELEASE-NAME
|
|
@ -0,0 +1,60 @@
|
|||
---
|
||||
suite: rbac metadata
|
||||
|
||||
set:
|
||||
serviceAccount:
|
||||
name: test-sa
|
||||
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/rbac_values.yaml
|
||||
tests:
|
||||
- it: default metadata should pass
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 4
|
||||
- documentIndex: &RoleDocument 2
|
||||
isKind:
|
||||
of: Role
|
||||
- documentIndex: *RoleDocument
|
||||
notExists:
|
||||
path: metadata.annotations
|
||||
- documentIndex: *RoleDocument
|
||||
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
|
||||
|
||||
- it: custom metadata should pass
|
||||
set:
|
||||
rbac:
|
||||
roles:
|
||||
defaultRole:
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 4
|
||||
- documentIndex: &RoleDocument 2
|
||||
isKind:
|
||||
of: Role
|
||||
- documentIndex: *RoleDocument
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
test_annotation: test
|
||||
- documentIndex: *RoleDocument
|
||||
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
|
||||
test_label: test
|
|
@ -0,0 +1,58 @@
|
|||
---
|
||||
suite: rbac names
|
||||
|
||||
set:
|
||||
serviceAccount:
|
||||
name: test-sa
|
||||
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/rbac_values.yaml
|
||||
tests:
|
||||
- it: default role and rolebinding names should pass
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 4
|
||||
- documentIndex: &RoleDocument 2
|
||||
isKind:
|
||||
of: Role
|
||||
- documentIndex: *RoleDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-defaultRole
|
||||
|
||||
- documentIndex: &BindingDocument 3
|
||||
isKind:
|
||||
of: RoleBinding
|
||||
- documentIndex: *BindingDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-defaultBinding
|
||||
|
||||
- it: custom role name should pass
|
||||
set:
|
||||
rbac:
|
||||
roles:
|
||||
defaultRole:
|
||||
forceRename: customRole
|
||||
bindings:
|
||||
defaultBinding:
|
||||
forceRename: customBinding
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 4
|
||||
- documentIndex: &RoleDocument 2
|
||||
isKind:
|
||||
of: Role
|
||||
- documentIndex: &BindingDocument 3
|
||||
isKind:
|
||||
of: RoleBinding
|
||||
- documentIndex: *RoleDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: customRole
|
||||
- documentIndex: *BindingDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: customBinding
|
|
@ -0,0 +1,44 @@
|
|||
---
|
||||
suite: rbac validations
|
||||
|
||||
set:
|
||||
serviceAccount:
|
||||
name: test-sa
|
||||
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/rbac_values.yaml
|
||||
tests:
|
||||
- it: role type must be valid
|
||||
set:
|
||||
rbac:
|
||||
roles:
|
||||
invalidRole:
|
||||
type: InvalidRole
|
||||
rules: {}
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: "You selected: `InvalidRole`. Type must be one of:"
|
||||
|
||||
- it: role rules can't be empty
|
||||
set:
|
||||
rbac:
|
||||
roles:
|
||||
invalidRole:
|
||||
type: Role
|
||||
rules: []
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: "Rules can't be empty"
|
||||
|
||||
- it: roleBinding requires roleRef
|
||||
set:
|
||||
rbac:
|
||||
bindings:
|
||||
invalidBinding:
|
||||
type: RoleBinding
|
||||
roleRef: {}
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: "If not using identifier roleRef must have a `name` key"
|
|
@ -0,0 +1,52 @@
|
|||
---
|
||||
suite: rbac values
|
||||
|
||||
set:
|
||||
serviceAccount:
|
||||
name: test-sa
|
||||
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/rbac_values.yaml
|
||||
tests:
|
||||
- it: default role and rolebinding should pass
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 4
|
||||
- documentIndex: &RoleDocument 2
|
||||
isKind:
|
||||
of: Role
|
||||
- documentIndex: *RoleDocument
|
||||
equal:
|
||||
path: rules[0].verbs
|
||||
value: ["get", "list"]
|
||||
|
||||
- documentIndex: &BindingDocument 3
|
||||
isKind:
|
||||
of: RoleBinding
|
||||
- documentIndex: *BindingDocument
|
||||
equal:
|
||||
path: subjects[0].name
|
||||
value: "test-sa"
|
||||
|
||||
- it: custom role values should pass
|
||||
set:
|
||||
rbac:
|
||||
roles:
|
||||
customRole:
|
||||
type: ClusterRole
|
||||
rules:
|
||||
- apiGroups: ["*"]
|
||||
resources: ["*"]
|
||||
verbs: ["get", "list", "watch"]
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 5
|
||||
- documentIndex: &RoleDocument 2
|
||||
isKind:
|
||||
of: ClusterRole
|
||||
- documentIndex: *RoleDocument
|
||||
equal:
|
||||
path: rules[0].verbs
|
||||
value: ["get", "list", "watch"]
|
|
@ -0,0 +1,94 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: route metadata
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default metadata should pass
|
||||
set:
|
||||
route.main:
|
||||
parentRefs:
|
||||
- name: test
|
||||
namespace: test
|
||||
asserts:
|
||||
- documentIndex: &routeDocument 1
|
||||
isKind:
|
||||
of: HTTPRoute
|
||||
- documentIndex: *routeDocument
|
||||
notExists:
|
||||
path: metadata.annotations
|
||||
- documentIndex: *routeDocument
|
||||
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
|
||||
|
||||
- it: custom metadata should pass
|
||||
set:
|
||||
route.main:
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
parentRefs:
|
||||
- name: test
|
||||
namespace: test
|
||||
asserts:
|
||||
- documentIndex: &routeDocument 1
|
||||
isKind:
|
||||
of: HTTPRoute
|
||||
- documentIndex: *routeDocument
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
test_annotation: test
|
||||
- documentIndex: *routeDocument
|
||||
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
|
||||
test_label: test
|
||||
|
||||
- it: custom metadata with global metadata should pass
|
||||
set:
|
||||
global:
|
||||
labels:
|
||||
global_label: test
|
||||
annotations:
|
||||
global_annotation: test
|
||||
route.main:
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
parentRefs:
|
||||
- name: test
|
||||
namespace: test
|
||||
asserts:
|
||||
- documentIndex: &routeDocument 1
|
||||
isKind:
|
||||
of: HTTPRoute
|
||||
- documentIndex: *routeDocument
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
global_annotation: test
|
||||
test_annotation: test
|
||||
- documentIndex: *routeDocument
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
global_label: test
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
test_label: test
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue