From 4863146ad971c49605eb2e67d865cfc136da466e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=E1=B4=87=CA=80=C9=B4=E1=B4=85=20S=E1=B4=84=CA=9C?= =?UTF-8?q?=E1=B4=8F=CA=80=C9=A2=E1=B4=87=CA=80s?= Date: Wed, 27 Jul 2022 19:40:55 +0200 Subject: [PATCH] More paving the way --- .ci/ct/ct.yaml | 3 +- .github/actions/collect-changes/action.yaml | 5 +- .github/workflows/charts-release.yaml | 2 +- charts/{stable => apps}/airsonic/.helmignore | 0 charts/{stable => apps}/airsonic/Chart.yaml | 2 +- charts/{stable => apps}/airsonic/README.md | 4 +- .../airsonic/README_CONFIG.md.gotmpl | 0 .../airsonic/templates/NOTES.txt | 0 .../airsonic/templates/common.yaml | 0 charts/{stable => apps}/airsonic/values.yaml | 2 +- .../alertmanager-bot/.helmignore | 0 .../alertmanager-bot/Chart.yaml | 2 +- .../alertmanager-bot/README.md | 4 +- .../alertmanager-bot/README_CONFIG.md.gotmpl | 0 .../alertmanager-bot/templates/NOTES.txt | 0 .../alertmanager-bot/templates/common.yaml | 0 .../alertmanager-bot/values.yaml | 2 +- charts/library/common/README.md | 2 +- charts/library/common/README.md.gotmpl | 2 +- charts/other/kah-common-chart/.helmignore | 26 +++ charts/other/kah-common-chart/Chart.yaml | 16 ++ .../kah-common-chart/README_CONFIG.md.gotmpl | 9 + .../kah-common-chart/templates/common.yaml | 2 + .../tests/addons/codeserver_test.yaml | 167 +++++++++++++++++ .../tests/addons/netshoot_test.yaml | 38 ++++ .../tests/addons/vpn_test.yaml | 131 ++++++++++++++ .../tests/configmap/metadata_test.yaml | 87 +++++++++ .../tests/configmap/names_test.yaml | 91 ++++++++++ .../tests/configmap/pod_metadata_test.yaml | 18 ++ .../tests/container/args_test.yaml | 41 +++++ .../tests/container/command_test.yaml | 41 +++++ .../tests/container/env_test.yaml | 169 ++++++++++++++++++ .../tests/container/envfrom_test.yaml | 43 +++++ .../tests/container/ports_test.yaml | 95 ++++++++++ .../tests/container/volumemounts_test.yaml | 122 +++++++++++++ .../controller/metadata_daemonset_test.yaml | 83 +++++++++ .../controller/metadata_deployment_test.yaml | 83 +++++++++ .../controller/metadata_statefulset_test.yaml | 83 +++++++++ .../tests/controller/type_test.yaml | 56 ++++++ .../tests/ingress/metadata_test.yaml | 83 +++++++++ .../tests/ingress/presence_test.yaml | 71 ++++++++ .../tests/ingress/service_reference_test.yaml | 39 ++++ .../tests/ingress/tls_test.yaml | 72 ++++++++ .../tests/ingress/values_test.yaml | 72 ++++++++ .../tests/persistence/claimnames_test.yaml | 78 ++++++++ .../tests/persistence/emptydir_test.yaml | 60 +++++++ .../tests/persistence/hostpath_test.yaml | 45 +++++ .../tests/persistence/types_test.yaml | 127 +++++++++++++ .../volumeclaimtemplates_test.yaml | 30 ++++ .../tests/pod/additionalcontainers_test.yaml | 45 +++++ .../tests/pod/initcontainers_test.yaml | 45 +++++ .../tests/pod/network_test.yaml | 59 ++++++ .../tests/pod/replicas_test.yaml | 25 +++ .../tests/pvc/metadata_test.yaml | 106 +++++++++++ .../tests/pvc/names_test.yaml | 66 +++++++ .../tests/pvc/storageclass_test.yaml | 42 +++++ .../tests/service/metadata_test.yaml | 81 +++++++++ .../tests/service/names_test.yaml | 29 +++ .../tests/service/port_names_test.yaml | 63 +++++++ .../tests/service/port_protocols_test.yaml | 71 ++++++++ .../tests/service/values_test.yaml | 33 ++++ charts/other/kah-common-chart/values.yaml | 1 + 62 files changed, 2761 insertions(+), 13 deletions(-) rename charts/{stable => apps}/airsonic/.helmignore (100%) rename charts/{stable => apps}/airsonic/Chart.yaml (90%) rename charts/{stable => apps}/airsonic/README.md (94%) rename charts/{stable => apps}/airsonic/README_CONFIG.md.gotmpl (100%) rename charts/{stable => apps}/airsonic/templates/NOTES.txt (100%) rename charts/{stable => apps}/airsonic/templates/common.yaml (100%) rename charts/{stable => apps}/airsonic/values.yaml (98%) rename charts/{stable => apps}/alertmanager-bot/.helmignore (100%) rename charts/{stable => apps}/alertmanager-bot/Chart.yaml (89%) rename charts/{stable => apps}/alertmanager-bot/README.md (94%) rename charts/{stable => apps}/alertmanager-bot/README_CONFIG.md.gotmpl (100%) rename charts/{stable => apps}/alertmanager-bot/templates/NOTES.txt (100%) rename charts/{stable => apps}/alertmanager-bot/templates/common.yaml (100%) rename charts/{stable => apps}/alertmanager-bot/values.yaml (97%) create mode 100644 charts/other/kah-common-chart/.helmignore create mode 100644 charts/other/kah-common-chart/Chart.yaml create mode 100644 charts/other/kah-common-chart/README_CONFIG.md.gotmpl create mode 100644 charts/other/kah-common-chart/templates/common.yaml create mode 100644 charts/other/kah-common-chart/tests/addons/codeserver_test.yaml create mode 100644 charts/other/kah-common-chart/tests/addons/netshoot_test.yaml create mode 100644 charts/other/kah-common-chart/tests/addons/vpn_test.yaml create mode 100644 charts/other/kah-common-chart/tests/configmap/metadata_test.yaml create mode 100644 charts/other/kah-common-chart/tests/configmap/names_test.yaml create mode 100644 charts/other/kah-common-chart/tests/configmap/pod_metadata_test.yaml create mode 100644 charts/other/kah-common-chart/tests/container/args_test.yaml create mode 100644 charts/other/kah-common-chart/tests/container/command_test.yaml create mode 100644 charts/other/kah-common-chart/tests/container/env_test.yaml create mode 100644 charts/other/kah-common-chart/tests/container/envfrom_test.yaml create mode 100644 charts/other/kah-common-chart/tests/container/ports_test.yaml create mode 100644 charts/other/kah-common-chart/tests/container/volumemounts_test.yaml create mode 100644 charts/other/kah-common-chart/tests/controller/metadata_daemonset_test.yaml create mode 100644 charts/other/kah-common-chart/tests/controller/metadata_deployment_test.yaml create mode 100644 charts/other/kah-common-chart/tests/controller/metadata_statefulset_test.yaml create mode 100644 charts/other/kah-common-chart/tests/controller/type_test.yaml create mode 100644 charts/other/kah-common-chart/tests/ingress/metadata_test.yaml create mode 100644 charts/other/kah-common-chart/tests/ingress/presence_test.yaml create mode 100644 charts/other/kah-common-chart/tests/ingress/service_reference_test.yaml create mode 100644 charts/other/kah-common-chart/tests/ingress/tls_test.yaml create mode 100644 charts/other/kah-common-chart/tests/ingress/values_test.yaml create mode 100644 charts/other/kah-common-chart/tests/persistence/claimnames_test.yaml create mode 100644 charts/other/kah-common-chart/tests/persistence/emptydir_test.yaml create mode 100644 charts/other/kah-common-chart/tests/persistence/hostpath_test.yaml create mode 100644 charts/other/kah-common-chart/tests/persistence/types_test.yaml create mode 100644 charts/other/kah-common-chart/tests/persistence/volumeclaimtemplates_test.yaml create mode 100644 charts/other/kah-common-chart/tests/pod/additionalcontainers_test.yaml create mode 100644 charts/other/kah-common-chart/tests/pod/initcontainers_test.yaml create mode 100644 charts/other/kah-common-chart/tests/pod/network_test.yaml create mode 100644 charts/other/kah-common-chart/tests/pod/replicas_test.yaml create mode 100644 charts/other/kah-common-chart/tests/pvc/metadata_test.yaml create mode 100644 charts/other/kah-common-chart/tests/pvc/names_test.yaml create mode 100644 charts/other/kah-common-chart/tests/pvc/storageclass_test.yaml create mode 100644 charts/other/kah-common-chart/tests/service/metadata_test.yaml create mode 100644 charts/other/kah-common-chart/tests/service/names_test.yaml create mode 100644 charts/other/kah-common-chart/tests/service/port_names_test.yaml create mode 100644 charts/other/kah-common-chart/tests/service/port_protocols_test.yaml create mode 100644 charts/other/kah-common-chart/tests/service/values_test.yaml create mode 100644 charts/other/kah-common-chart/values.yaml diff --git a/.ci/ct/ct.yaml b/.ci/ct/ct.yaml index 1cac46ef..4491bcbd 100644 --- a/.ci/ct/ct.yaml +++ b/.ci/ct/ct.yaml @@ -8,7 +8,8 @@ helm-extra-args: --timeout 600s chart-dirs: - charts/library - - charts/stable + - charts/apps + - charts/other excluded-charts-lint: [] diff --git a/.github/actions/collect-changes/action.yaml b/.github/actions/collect-changes/action.yaml index eb42ef3a..574a1db7 100644 --- a/.github/actions/collect-changes/action.yaml +++ b/.github/actions/collect-changes/action.yaml @@ -18,8 +18,11 @@ outputs: description: "Whether or not changes to charts have been detected" value: ${{ steps.filter.outputs.chartsAddedOrModified }} addedOrModifiedFiles: - description: "A list of the files changed" + description: "A list of the files that changed" value: ${{ steps.filter.outputs.addedOrModified_files }} + addedOrModifiedChartFiles: + description: "A list of the chart files that changed" + value: ${{ steps.filter.outputs.chartsAddedOrModified_files }} addedOrModifiedCharts: description: "A list of the charts changed" value: ${{ steps.changed-charts.outputs.addedOrModifiedCharts }} diff --git a/.github/workflows/charts-release.yaml b/.github/workflows/charts-release.yaml index 9200542a..30ad6379 100644 --- a/.github/workflows/charts-release.yaml +++ b/.github/workflows/charts-release.yaml @@ -55,7 +55,7 @@ jobs: else CHARTS=(${{ github.event.inputs.chart }}) fi - elif [ "${{ steps.collect-changes.outputs.chartsAddedOrModified }}" == "true" ]; then + elif [ "${{ steps.collect-changes.outputs.chartChangesDetected }}" == "true" ]; then CHARTS=(${{ steps.collect-changes.outputs.addedOrModifiedCharts }}) fi printf "::set-output name=charts::%s\n" "${CHARTS[*]}" diff --git a/charts/stable/airsonic/.helmignore b/charts/apps/airsonic/.helmignore similarity index 100% rename from charts/stable/airsonic/.helmignore rename to charts/apps/airsonic/.helmignore diff --git a/charts/stable/airsonic/Chart.yaml b/charts/apps/airsonic/Chart.yaml similarity index 90% rename from charts/stable/airsonic/Chart.yaml rename to charts/apps/airsonic/Chart.yaml index e5305b6b..15a6c9b2 100644 --- a/charts/stable/airsonic/Chart.yaml +++ b/charts/apps/airsonic/Chart.yaml @@ -7,7 +7,7 @@ version: 6.3.2 kubeVersion: ">=1.16.0-0" keywords: - airsonic -home: https://github.com/k8s-at-home/charts/tree/master/charts/stable/airsonic +home: https://github.com/k8s-at-home/charts/tree/master/charts/apps/airsonic icon: https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/airsonic-logo.png sources: - https://github.com/airsonic-advanced/airsonic-advanced diff --git a/charts/stable/airsonic/README.md b/charts/apps/airsonic/README.md similarity index 94% rename from charts/stable/airsonic/README.md rename to charts/apps/airsonic/README.md index 88122d66..19e9194d 100644 --- a/charts/stable/airsonic/README.md +++ b/charts/apps/airsonic/README.md @@ -50,7 +50,7 @@ The command removes all the Kubernetes components associated with the chart **in ## Configuration Read through the [values.yaml](./values.yaml) file. It has several commented out suggested values. -Other values may be used from the [values.yaml](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common/values.yaml) from the [common library](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common). +Other values may be used from the [values.yaml](https://github.com/k8s-at-home/library-charts/tree/main/charts/apps/common/values.yaml) from the [common library](https://github.com/k8s-at-home/library-charts/tree/main/charts/apps/common). Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. @@ -74,7 +74,7 @@ by not constantly monitoring media folders. ## Values -**Important**: When deploying an application Helm chart you can add more values from our common library chart [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common) +**Important**: When deploying an application Helm chart you can add more values from our common library chart [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/apps/common) | Key | Type | Default | Description | |-----|------|---------|-------------| diff --git a/charts/stable/airsonic/README_CONFIG.md.gotmpl b/charts/apps/airsonic/README_CONFIG.md.gotmpl similarity index 100% rename from charts/stable/airsonic/README_CONFIG.md.gotmpl rename to charts/apps/airsonic/README_CONFIG.md.gotmpl diff --git a/charts/stable/airsonic/templates/NOTES.txt b/charts/apps/airsonic/templates/NOTES.txt similarity index 100% rename from charts/stable/airsonic/templates/NOTES.txt rename to charts/apps/airsonic/templates/NOTES.txt diff --git a/charts/stable/airsonic/templates/common.yaml b/charts/apps/airsonic/templates/common.yaml similarity index 100% rename from charts/stable/airsonic/templates/common.yaml rename to charts/apps/airsonic/templates/common.yaml diff --git a/charts/stable/airsonic/values.yaml b/charts/apps/airsonic/values.yaml similarity index 98% rename from charts/stable/airsonic/values.yaml rename to charts/apps/airsonic/values.yaml index 96fd4467..04b9addf 100644 --- a/charts/stable/airsonic/values.yaml +++ b/charts/apps/airsonic/values.yaml @@ -2,7 +2,7 @@ # IMPORTANT NOTE # # This chart inherits from our common library chart. You can check the default values/options here: -# https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common/values.yaml +# https://github.com/k8s-at-home/library-charts/tree/main/charts/apps/common/values.yaml # image: diff --git a/charts/stable/alertmanager-bot/.helmignore b/charts/apps/alertmanager-bot/.helmignore similarity index 100% rename from charts/stable/alertmanager-bot/.helmignore rename to charts/apps/alertmanager-bot/.helmignore diff --git a/charts/stable/alertmanager-bot/Chart.yaml b/charts/apps/alertmanager-bot/Chart.yaml similarity index 89% rename from charts/stable/alertmanager-bot/Chart.yaml rename to charts/apps/alertmanager-bot/Chart.yaml index 5e851e5e..84f1844c 100644 --- a/charts/stable/alertmanager-bot/Chart.yaml +++ b/charts/apps/alertmanager-bot/Chart.yaml @@ -10,7 +10,7 @@ keywords: - telegram - bot - alerting -home: https://github.com/k8s-at-home/charts/tree/master/charts/stable/alertmanager-bot +home: https://github.com/k8s-at-home/charts/tree/master/charts/apps/alertmanager-bot icon: https://raw.githubusercontent.com/prometheus/prometheus.github.io/master/assets/prometheus_logo-cb55bb5c346.png sources: - https://hub.docker.com/r/metalmatze/alertmanager-bot diff --git a/charts/stable/alertmanager-bot/README.md b/charts/apps/alertmanager-bot/README.md similarity index 94% rename from charts/stable/alertmanager-bot/README.md rename to charts/apps/alertmanager-bot/README.md index 71ddc8ce..216d13a3 100644 --- a/charts/stable/alertmanager-bot/README.md +++ b/charts/apps/alertmanager-bot/README.md @@ -50,7 +50,7 @@ The command removes all the Kubernetes components associated with the chart **in ## Configuration Read through the [values.yaml](./values.yaml) file. It has several commented out suggested values. -Other values may be used from the [values.yaml](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common/values.yaml) from the [common library](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common). +Other values may be used from the [values.yaml](https://github.com/k8s-at-home/library-charts/tree/main/charts/apps/common/values.yaml) from the [common library](https://github.com/k8s-at-home/library-charts/tree/main/charts/apps/common). Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. @@ -72,7 +72,7 @@ N/A ## Values -**Important**: When deploying an application Helm chart you can add more values from our common library chart [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common) +**Important**: When deploying an application Helm chart you can add more values from our common library chart [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/apps/common) | Key | Type | Default | Description | |-----|------|---------|-------------| diff --git a/charts/stable/alertmanager-bot/README_CONFIG.md.gotmpl b/charts/apps/alertmanager-bot/README_CONFIG.md.gotmpl similarity index 100% rename from charts/stable/alertmanager-bot/README_CONFIG.md.gotmpl rename to charts/apps/alertmanager-bot/README_CONFIG.md.gotmpl diff --git a/charts/stable/alertmanager-bot/templates/NOTES.txt b/charts/apps/alertmanager-bot/templates/NOTES.txt similarity index 100% rename from charts/stable/alertmanager-bot/templates/NOTES.txt rename to charts/apps/alertmanager-bot/templates/NOTES.txt diff --git a/charts/stable/alertmanager-bot/templates/common.yaml b/charts/apps/alertmanager-bot/templates/common.yaml similarity index 100% rename from charts/stable/alertmanager-bot/templates/common.yaml rename to charts/apps/alertmanager-bot/templates/common.yaml diff --git a/charts/stable/alertmanager-bot/values.yaml b/charts/apps/alertmanager-bot/values.yaml similarity index 97% rename from charts/stable/alertmanager-bot/values.yaml rename to charts/apps/alertmanager-bot/values.yaml index edfecf4d..115132bb 100644 --- a/charts/stable/alertmanager-bot/values.yaml +++ b/charts/apps/alertmanager-bot/values.yaml @@ -2,7 +2,7 @@ # IMPORTANT NOTE # # This chart inherits from our common library chart. You can check the default values/options here: -# https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common/values.yaml +# https://github.com/k8s-at-home/library-charts/tree/main/charts/apps/common/values.yaml # image: diff --git a/charts/library/common/README.md b/charts/library/common/README.md index 188b2625..0cf8b7d4 100644 --- a/charts/library/common/README.md +++ b/charts/library/common/README.md @@ -45,7 +45,7 @@ N/A ## Values -**Important**: When deploying an application Helm chart you can add more values from our common library chart [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common) +**Important**: When deploying an application Helm chart you can add more values from our common library chart [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/apps/common) | Key | Type | Default | Description | |-----|------|---------|-------------| diff --git a/charts/library/common/README.md.gotmpl b/charts/library/common/README.md.gotmpl index a5d5a8cc..01053e05 100644 --- a/charts/library/common/README.md.gotmpl +++ b/charts/library/common/README.md.gotmpl @@ -51,7 +51,7 @@ Read through the [values.yaml](./values.yaml) file. It has several commented out {{- define "custom.valuesSection" -}} ## Values -**Important**: When deploying an application Helm chart you can add more values from our common library chart [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common) +**Important**: When deploying an application Helm chart you can add more values from our common library chart [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/apps/common) {{ template "chart.valuesTable" . }} {{- end -}} diff --git a/charts/other/kah-common-chart/.helmignore b/charts/other/kah-common-chart/.helmignore new file mode 100644 index 00000000..4379e2b3 --- /dev/null +++ b/charts/other/kah-common-chart/.helmignore @@ -0,0 +1,26 @@ +# 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 diff --git a/charts/other/kah-common-chart/Chart.yaml b/charts/other/kah-common-chart/Chart.yaml new file mode 100644 index 00000000..0a596e7b --- /dev/null +++ b/charts/other/kah-common-chart/Chart.yaml @@ -0,0 +1,16 @@ +--- +apiVersion: v2 +description: A KaH-common powered chart template. This can be useful for small projects that don't have their own chart. +name: kah-common-chart +version: 1.1.2 +maintainers: + - name: bjw-s + email: me@bjw-s.dev +dependencies: + - name: common + repository: https://library-charts.k8s-at-home.com + version: 4.4.2 +annotations: + artifacthub.io/changes: |- + - kind: changed + description: Upgraded `common` chart dependency to version 4.4.2 diff --git a/charts/other/kah-common-chart/README_CONFIG.md.gotmpl b/charts/other/kah-common-chart/README_CONFIG.md.gotmpl new file mode 100644 index 00000000..e93d80bf --- /dev/null +++ b/charts/other/kah-common-chart/README_CONFIG.md.gotmpl @@ -0,0 +1,9 @@ +{{- define "custom.custom.configuration.header" -}} +## Custom configuration +{{- end -}} + +{{- define "custom.custom.configuration" -}} +{{ template "custom.custom.configuration.header" . }} + +N/A +{{- end -}} diff --git a/charts/other/kah-common-chart/templates/common.yaml b/charts/other/kah-common-chart/templates/common.yaml new file mode 100644 index 00000000..7a9d0361 --- /dev/null +++ b/charts/other/kah-common-chart/templates/common.yaml @@ -0,0 +1,2 @@ +--- +{{ include "common.all" . }} diff --git a/charts/other/kah-common-chart/tests/addons/codeserver_test.yaml b/charts/other/kah-common-chart/tests/addons/codeserver_test.yaml new file mode 100644 index 00000000..d75a66a4 --- /dev/null +++ b/charts/other/kah-common-chart/tests/addons/codeserver_test.yaml @@ -0,0 +1,167 @@ +suite: addon codeserver +templates: + - common.yaml +tests: + - it: default should pass + asserts: + - hasDocuments: + count: 2 + - documentIndex: &DeploymentDocument 0 + isKind: + of: Deployment + - documentIndex: 1 + isKind: + of: Service + - documentIndex: *DeploymentDocument + not: true + equal: + path: spec.template.spec.containers[0].name + value: codeserver + + - it: addon enabled should pass + set: + addons: + codeserver: + enabled: true + volumeMounts: + - name: "config" + mountPath: "/data/config" + asserts: + - hasDocuments: + count: 3 + - documentIndex: 0 + isKind: + of: Service + - documentIndex: &DeploymentDocument 1 + isKind: + of: Deployment + - documentIndex: &AddonServiceDocument 2 + isKind: + of: Service + - documentIndex: *DeploymentDocument + equal: + path: spec.template.spec.containers[1].name + value: codeserver + - documentIndex: *AddonServiceDocument + equal: + path: metadata.name + value: RELEASE-NAME-common-test + + - it: addon enabled with deployKey should pass + set: + addons: + codeserver: + enabled: true + git: + deployKey: test + volumeMounts: + - name: "config" + mountPath: "/data/config" + asserts: + - hasDocuments: + count: 4 + - documentIndex: &AddonDeployKeySecretDocument 0 + isKind: + of: Secret + - documentIndex: &DeploymentDocument 2 + isKind: + of: Deployment + - documentIndex: *DeploymentDocument + contains: + path: spec.template.spec.containers[1].volumeMounts + content: + mountPath: /root/.ssh/id_rsa + name: deploykey + subPath: id_rsa + - documentIndex: *DeploymentDocument + contains: + path: spec.template.spec.volumes + content: + name: deploykey + secret: + defaultMode: 256 + items: + - key: id_rsa + path: id_rsa + secretName: RELEASE-NAME-common-test-deploykey + - documentIndex: *AddonDeployKeySecretDocument + equal: + path: metadata.name + value: RELEASE-NAME-common-test-deploykey + + - it: addon enabled with InlineBase64 deployKey should pass + set: + addons: + codeserver: + enabled: true + git: + deployKeyBase64: dGVzdEtleQ== + volumeMounts: + - name: "config" + mountPath: "/data/config" + asserts: + - hasDocuments: + count: 4 + - documentIndex: &AddonDeployKeySecretDocument 0 + isKind: + of: Secret + - documentIndex: &DeploymentDocument 2 + isKind: + of: Deployment + - documentIndex: *DeploymentDocument + contains: + path: spec.template.spec.containers[1].volumeMounts + content: + mountPath: /root/.ssh/id_rsa + name: deploykey + subPath: id_rsa + - documentIndex: *DeploymentDocument + contains: + path: spec.template.spec.volumes + content: + name: deploykey + secret: + defaultMode: 256 + items: + - key: id_rsa + path: id_rsa + secretName: RELEASE-NAME-common-test-deploykey + - documentIndex: *AddonDeployKeySecretDocument + equal: + path: metadata.name + value: RELEASE-NAME-common-test-deploykey + + - it: addon enabled with existingSecret deployKey should pass + set: + addons: + codeserver: + enabled: true + git: + deployKeySecret: test-secret + volumeMounts: + - name: "config" + mountPath: "/data/config" + asserts: + - hasDocuments: + count: 3 + - documentIndex: &DeploymentDocument 1 + isKind: + of: Deployment + - documentIndex: *DeploymentDocument + contains: + path: spec.template.spec.containers[1].volumeMounts + content: + mountPath: /root/.ssh/id_rsa + name: deploykey + subPath: id_rsa + - documentIndex: *DeploymentDocument + contains: + path: spec.template.spec.volumes + content: + name: deploykey + secret: + defaultMode: 256 + items: + - key: id_rsa + path: id_rsa + secretName: test-secret diff --git a/charts/other/kah-common-chart/tests/addons/netshoot_test.yaml b/charts/other/kah-common-chart/tests/addons/netshoot_test.yaml new file mode 100644 index 00000000..45b2967e --- /dev/null +++ b/charts/other/kah-common-chart/tests/addons/netshoot_test.yaml @@ -0,0 +1,38 @@ +suite: addon netshoot +templates: + - common.yaml +tests: + - it: default should pass + asserts: + - hasDocuments: + count: 2 + - documentIndex: &DeploymentDocument 0 + isKind: + of: Deployment + - documentIndex: 1 + isKind: + of: Service + - documentIndex: *DeploymentDocument + not: true + equal: + path: spec.template.spec.containers[0].name + value: netshoot + + - it: addon enabled should pass + set: + addons: + netshoot: + enabled: true + asserts: + - hasDocuments: + count: 2 + - documentIndex: &DeploymentDocument 0 + isKind: + of: Deployment + - documentIndex: 1 + isKind: + of: Service + - documentIndex: *DeploymentDocument + equal: + path: spec.template.spec.containers[1].name + value: netshoot diff --git a/charts/other/kah-common-chart/tests/addons/vpn_test.yaml b/charts/other/kah-common-chart/tests/addons/vpn_test.yaml new file mode 100644 index 00000000..57c09758 --- /dev/null +++ b/charts/other/kah-common-chart/tests/addons/vpn_test.yaml @@ -0,0 +1,131 @@ +suite: addon vpn +templates: + - common.yaml +tests: + - it: default should pass + asserts: + - hasDocuments: + count: 2 + - documentIndex: &DeploymentDocument 0 + isKind: + of: Deployment + - documentIndex: 1 + isKind: + of: Service + - documentIndex: *DeploymentDocument + not: true + equal: + path: spec.template.spec.containers[0].name + value: vpn + + - it: addon enabled should pass + set: + addons: + vpn: + enabled: true + asserts: + - hasDocuments: + count: 2 + - documentIndex: &DeploymentDocument 0 + isKind: + of: Deployment + - documentIndex: 1 + isKind: + of: Service + - documentIndex: *DeploymentDocument + equal: + path: spec.template.spec.containers[1].name + value: openvpn + + - it: addon enabled with configFile should pass + set: + addons: + vpn: + enabled: true + configFile: test + asserts: + - hasDocuments: + count: 3 + - documentIndex: &AddonVPNConfigSecretDocument 0 + isKind: + of: Secret + - documentIndex: &DeploymentDocument 1 + isKind: + of: Deployment + - documentIndex: *DeploymentDocument + contains: + path: spec.template.spec.containers[1].volumeMounts + content: + mountPath: /vpn/vpn.conf + name: vpnconfig + subPath: vpnConfigfile + - documentIndex: *DeploymentDocument + contains: + path: spec.template.spec.volumes + content: + name: vpnconfig + secret: + items: + - key: vpnConfigfile + path: vpnConfigfile + secretName: RELEASE-NAME-common-test-vpnconfig + - documentIndex: *AddonVPNConfigSecretDocument + equal: + path: metadata.name + value: RELEASE-NAME-common-test-vpnconfig + + - it: addon enabled with existing configFile secret should pass + set: + addons: + vpn: + enabled: true + configFileSecret: test-secret + asserts: + - hasDocuments: + count: 2 + - documentIndex: &DeploymentDocument 0 + isKind: + of: Deployment + - documentIndex: *DeploymentDocument + contains: + path: spec.template.spec.containers[1].volumeMounts + content: + mountPath: /vpn/vpn.conf + name: vpnconfig + subPath: vpnConfigfile + - documentIndex: *DeploymentDocument + contains: + path: spec.template.spec.volumes + content: + name: vpnconfig + secret: + items: + - key: vpnConfigfile + path: vpnConfigfile + secretName: test-secret + + - it: addon enabled with managed secret should pass + set: + addons: + vpn: + enabled: true + openvpn: + auth: | + + asserts: + - hasDocuments: + count: 3 + - documentIndex: &SecretDocument 0 + isKind: + of: Secret + - documentIndex: &DeploymentDocument 1 + isKind: + of: Deployment + - documentIndex: 2 + isKind: + of: Service + - documentIndex: *DeploymentDocument + not: true + equal: + path: spec.template.spec.containers[0].name + value: vpn diff --git a/charts/other/kah-common-chart/tests/configmap/metadata_test.yaml b/charts/other/kah-common-chart/tests/configmap/metadata_test.yaml new file mode 100644 index 00000000..f835e1b7 --- /dev/null +++ b/charts/other/kah-common-chart/tests/configmap/metadata_test.yaml @@ -0,0 +1,87 @@ +suite: configmap metadata +templates: + - common.yaml +tests: + - it: default metadata should pass + set: + configmap: + config: + enabled: true + asserts: + - documentIndex: &ConfigmapDocument 0 + isKind: + of: ConfigMap + - documentIndex: *ConfigmapDocument + isNull: + 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: common-test + helm.sh/chart: common-test-0.1.0 + + - it: custom metadata should pass + set: + configmap: + config: + enabled: true + annotations: + test_annotation: test + labels: + test_label: test + asserts: + - 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: common-test + helm.sh/chart: common-test-0.1.0 + test_label: test + + - it: custom metadata with global metadata should pass + set: + global: + labels: + global_label: test + annotations: + global_annotation: test + configmap: + config: + enabled: true + annotations: + test_annotation: test + labels: + test_label: test + asserts: + - 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: common-test + global_label: test + helm.sh/chart: common-test-0.1.0 + test_label: test diff --git a/charts/other/kah-common-chart/tests/configmap/names_test.yaml b/charts/other/kah-common-chart/tests/configmap/names_test.yaml new file mode 100644 index 00000000..764e75fa --- /dev/null +++ b/charts/other/kah-common-chart/tests/configmap/names_test.yaml @@ -0,0 +1,91 @@ +suite: configMap names +templates: + - common.yaml +tests: + - it: default should pass + asserts: + - hasDocuments: + count: 2 + - documentIndex: 0 + not: true + isKind: + of: ConfigMap + - documentIndex: 1 + not: true + isKind: + of: ConfigMap + + - it: with disabled configMap should pass + set: + configmap: + config: + enabled: false + asserts: + - hasDocuments: + count: 2 + - documentIndex: 0 + not: true + isKind: + of: ConfigMap + - documentIndex: 1 + not: true + isKind: + of: ConfigMap + + - it: with multiple configMap should pass + set: + configmap: + config: + enabled: true + data: + foo: bar + secondary: + enabled: true + asserts: + - hasDocuments: + count: 4 + - documentIndex: 0 + isKind: + of: ConfigMap + - documentIndex: 0 + isNotNull: + path: metadata.name + - documentIndex: 1 + isKind: + of: ConfigMap + - documentIndex: 1 + isNotNull: + path: metadata.name + + - it: default name should pass + set: + configmap: + config: + enabled: true + asserts: + - hasDocuments: + count: 3 + - documentIndex: 0 + isKind: + of: ConfigMap + - documentIndex: 0 + equal: + path: metadata.name + value: RELEASE-NAME-common-test-config + + - it: with nameOverride should pass + set: + configmap: + config: + enabled: true + nameOverride: http + asserts: + - hasDocuments: + count: 3 + - documentIndex: 0 + isKind: + of: ConfigMap + - documentIndex: 0 + equal: + path: metadata.name + value: RELEASE-NAME-common-test-http diff --git a/charts/other/kah-common-chart/tests/configmap/pod_metadata_test.yaml b/charts/other/kah-common-chart/tests/configmap/pod_metadata_test.yaml new file mode 100644 index 00000000..5c3fc3e4 --- /dev/null +++ b/charts/other/kah-common-chart/tests/configmap/pod_metadata_test.yaml @@ -0,0 +1,18 @@ +suite: configmap Pod metadata +templates: + - common.yaml +tests: + - it: default metadata should pass + set: + configmap: + config: + enabled: true + asserts: + - documentIndex: &ControllerDoc 1 + isKind: + of: Deployment + - documentIndex: *ControllerDoc + equal: + path: spec.template.metadata.annotations + value: + checksum/config: 13f83afec54139bc9b797ac55ba4d79494f6fd94c0159101836ef127bec95a28 diff --git a/charts/other/kah-common-chart/tests/container/args_test.yaml b/charts/other/kah-common-chart/tests/container/args_test.yaml new file mode 100644 index 00000000..b17ddedb --- /dev/null +++ b/charts/other/kah-common-chart/tests/container/args_test.yaml @@ -0,0 +1,41 @@ +suite: container args override +templates: + - common.yaml +tests: + - it: default should pass + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + isNull: + path: spec.template.spec.containers[0].args + + - it: single string should pass + set: + 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: + args: + - sleep + - infinity + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].args + value: + - sleep + - infinity diff --git a/charts/other/kah-common-chart/tests/container/command_test.yaml b/charts/other/kah-common-chart/tests/container/command_test.yaml new file mode 100644 index 00000000..78c272b7 --- /dev/null +++ b/charts/other/kah-common-chart/tests/container/command_test.yaml @@ -0,0 +1,41 @@ +suite: container command override +templates: + - common.yaml +tests: + - it: default should pass + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + isNull: + path: spec.template.spec.containers[0].command + + - it: single string should pass + set: + 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: + command: + - /bin/sh + - -c + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].command + value: + - /bin/sh + - -c diff --git a/charts/other/kah-common-chart/tests/container/env_test.yaml b/charts/other/kah-common-chart/tests/container/env_test.yaml new file mode 100644 index 00000000..11e5a7af --- /dev/null +++ b/charts/other/kah-common-chart/tests/container/env_test.yaml @@ -0,0 +1,169 @@ +suite: container env values +templates: + - common.yaml +tests: + - it: default should pass + asserts: + - documentIndex: &DeploymentDoc 0 + isKind: + of: Deployment + - documentIndex: *DeploymentDoc + isNull: + path: spec.template.spec.containers[0].env + + - it: KeyValue string should pass + set: + 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: + 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: + 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: KeyValue float should pass + set: + 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: List should pass + set: + 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: + 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 should pass + set: + 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: + env: + DYNAMIC_ENV: "{{ .Release.Name }}-admin" + 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 + + - it: Combined KeyValue with Explicit ValueFrom should pass + set: + 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 diff --git a/charts/other/kah-common-chart/tests/container/envfrom_test.yaml b/charts/other/kah-common-chart/tests/container/envfrom_test.yaml new file mode 100644 index 00000000..2ef9c8d7 --- /dev/null +++ b/charts/other/kah-common-chart/tests/container/envfrom_test.yaml @@ -0,0 +1,43 @@ +suite: container envFrom values +templates: + - common.yaml +tests: + - it: default should pass + asserts: + - documentIndex: &DeploymentDoc 0 + isKind: + of: Deployment + - documentIndex: *DeploymentDoc + isNull: + path: spec.template.spec.containers[0].envFrom + + - it: explicit envFrom should pass + set: + envFrom: + - secretRef: + name: myCustomSecret + asserts: + - documentIndex: &DeploymentDoc 0 + isKind: + of: Deployment + - documentIndex: *DeploymentDoc + equal: + path: spec.template.spec.containers[0].envFrom[0] + value: + secretRef: + name: myCustomSecret + + - it: from secret should pass + set: + secret: + STATIC_SECRET: value_of_secret + asserts: + - documentIndex: &DeploymentDoc 0 + isKind: + of: Deployment + - documentIndex: *DeploymentDoc + equal: + path: spec.template.spec.containers[0].envFrom[0] + value: + secretRef: + name: RELEASE-NAME-common-test diff --git a/charts/other/kah-common-chart/tests/container/ports_test.yaml b/charts/other/kah-common-chart/tests/container/ports_test.yaml new file mode 100644 index 00000000..3dea0973 --- /dev/null +++ b/charts/other/kah-common-chart/tests/container/ports_test.yaml @@ -0,0 +1,95 @@ +suite: container ports +templates: + - common.yaml +tests: + - it: default should pass + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].ports[0] + value: + containerPort: null + name: http + protocol: TCP + + - it: custom port should pass + set: + service: + main: + ports: + http: + enabled: false + server: + enabled: true + port: 8080 + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].ports[0] + value: + containerPort: 8080 + name: server + protocol: TCP + + - it: HTTP protocol should pass + set: + service: + main: + ports: + http: + protocol: HTTP + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].ports[0] + value: + containerPort: null + name: http + protocol: TCP + + - it: HTTPS protocol should pass + set: + service: + main: + ports: + http: + protocol: HTTPS + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].ports[0] + value: + containerPort: null + name: http + protocol: TCP + + - it: UDP protocol should pass + set: + service: + main: + ports: + http: + protocol: UDP + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].ports[0] + value: + containerPort: null + name: http + protocol: UDP diff --git a/charts/other/kah-common-chart/tests/container/volumemounts_test.yaml b/charts/other/kah-common-chart/tests/container/volumemounts_test.yaml new file mode 100644 index 00000000..121f17d0 --- /dev/null +++ b/charts/other/kah-common-chart/tests/container/volumemounts_test.yaml @@ -0,0 +1,122 @@ +suite: container volumeMounts +templates: + - common.yaml +tests: + - it: no persistence should pass + asserts: + - documentIndex: &DeploymentDoc 0 + isKind: + of: Deployment + - documentIndex: *DeploymentDoc + isNull: + path: spec.template.spec.containers[0].volumeMounts + + - it: default should pass + set: + persistence: + config: + enabled: true + asserts: + - documentIndex: &DeploymentDoc 1 + isKind: + of: Deployment + - documentIndex: *DeploymentDoc + equal: + path: spec.template.spec.containers[0].volumeMounts[0] + value: + name: config + mountPath: /config + + - it: emptyDir should pass + set: + persistence: + cache: + enabled: true + 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: + enabled: true + mountPath: /custom + accessMode: ReadWriteMany + size: 1G + 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: + enabled: true + existingClaim: myClaim + 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: + enabled: true + type: hostPath + mountPath: /data + hostPath: /tmp + 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: + enabled: true + type: hostPath + hostPath: /dev + 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 diff --git a/charts/other/kah-common-chart/tests/controller/metadata_daemonset_test.yaml b/charts/other/kah-common-chart/tests/controller/metadata_daemonset_test.yaml new file mode 100644 index 00000000..aa01059e --- /dev/null +++ b/charts/other/kah-common-chart/tests/controller/metadata_daemonset_test.yaml @@ -0,0 +1,83 @@ +suite: controller metadata daemonset +templates: + - common.yaml +tests: + - it: default metadata should pass + set: + controller.type: daemonset + asserts: + - documentIndex: &ControllerDoc 0 + isKind: + of: DaemonSet + - documentIndex: *ControllerDoc + isNull: + path: metadata.annotations + - documentIndex: *ControllerDoc + equal: + path: metadata.labels + value: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: common-test + helm.sh/chart: common-test-0.1.0 + + - it: custom metadata should pass + set: + controller: + 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/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: common-test + helm.sh/chart: common-test-0.1.0 + test_label: test + + - it: custom metadata with global metadata should pass + set: + global: + labels: + global_label: test + annotations: + global_annotation: test + controller: + 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/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: common-test + global_label: test + helm.sh/chart: common-test-0.1.0 + test_label: test diff --git a/charts/other/kah-common-chart/tests/controller/metadata_deployment_test.yaml b/charts/other/kah-common-chart/tests/controller/metadata_deployment_test.yaml new file mode 100644 index 00000000..37ebeb69 --- /dev/null +++ b/charts/other/kah-common-chart/tests/controller/metadata_deployment_test.yaml @@ -0,0 +1,83 @@ +suite: controller metadata deployment +templates: + - common.yaml +tests: + - it: default metadata should pass + set: + controller.type: deployment + asserts: + - documentIndex: &ControllerDoc 0 + isKind: + of: Deployment + - documentIndex: *ControllerDoc + isNull: + path: metadata.annotations + - documentIndex: *ControllerDoc + equal: + path: metadata.labels + value: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: common-test + helm.sh/chart: common-test-0.1.0 + + - it: custom metadata should pass + set: + controller: + 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/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: common-test + helm.sh/chart: common-test-0.1.0 + test_label: test + + - it: custom metadata with global metadata should pass + set: + global: + labels: + global_label: test + annotations: + global_annotation: test + controller: + 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/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: common-test + global_label: test + helm.sh/chart: common-test-0.1.0 + test_label: test diff --git a/charts/other/kah-common-chart/tests/controller/metadata_statefulset_test.yaml b/charts/other/kah-common-chart/tests/controller/metadata_statefulset_test.yaml new file mode 100644 index 00000000..cd5ea5e8 --- /dev/null +++ b/charts/other/kah-common-chart/tests/controller/metadata_statefulset_test.yaml @@ -0,0 +1,83 @@ +suite: controller metadata statefulset +templates: + - common.yaml +tests: + - it: default metadata should pass + set: + controller.type: statefulset + asserts: + - documentIndex: &ControllerDoc 0 + isKind: + of: StatefulSet + - documentIndex: *ControllerDoc + isNull: + path: metadata.annotations + - documentIndex: *ControllerDoc + equal: + path: metadata.labels + value: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: common-test + helm.sh/chart: common-test-0.1.0 + + - it: custom metadata should pass + set: + controller: + 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/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: common-test + helm.sh/chart: common-test-0.1.0 + test_label: test + + - it: custom metadata with global metadata should pass + set: + global: + labels: + global_label: test + annotations: + global_annotation: test + controller: + 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/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: common-test + global_label: test + helm.sh/chart: common-test-0.1.0 + test_label: test diff --git a/charts/other/kah-common-chart/tests/controller/type_test.yaml b/charts/other/kah-common-chart/tests/controller/type_test.yaml new file mode 100644 index 00000000..59bb9fe8 --- /dev/null +++ b/charts/other/kah-common-chart/tests/controller/type_test.yaml @@ -0,0 +1,56 @@ +suite: controller types +templates: + - common.yaml +tests: + - it: default should pass + asserts: + - documentIndex: &ControllerDoc 0 + isKind: + of: Deployment + - documentIndex: *ControllerDoc + equal: + path: metadata.name + value: RELEASE-NAME-common-test + + - it: daemonset should pass + set: + controller.type: daemonset + asserts: + - documentIndex: &ControllerDoc 0 + isKind: + of: DaemonSet + - documentIndex: *ControllerDoc + equal: + path: metadata.name + value: RELEASE-NAME-common-test + + - it: statefulset should pass + set: + controller.type: statefulset + asserts: + - documentIndex: &ControllerDoc 0 + isKind: + of: StatefulSet + - documentIndex: *ControllerDoc + equal: + path: metadata.name + value: RELEASE-NAME-common-test + + - it: disabled should pass + set: + controller.enabled: false + asserts: + - hasDocuments: + count: 1 + - documentIndex: &ControllerDoc 0 + not: true + isKind: + of: StatefulSet + - documentIndex: *ControllerDoc + not: true + isKind: + of: DaemonSet + - documentIndex: *ControllerDoc + not: true + isKind: + of: Controller diff --git a/charts/other/kah-common-chart/tests/ingress/metadata_test.yaml b/charts/other/kah-common-chart/tests/ingress/metadata_test.yaml new file mode 100644 index 00000000..a0fad8a8 --- /dev/null +++ b/charts/other/kah-common-chart/tests/ingress/metadata_test.yaml @@ -0,0 +1,83 @@ +suite: ingress metadata +templates: + - common.yaml +tests: + - it: default metadata should pass + set: + ingress.main.enabled: true + asserts: + - documentIndex: &IngressDocument 2 + isKind: + of: Ingress + - documentIndex: *IngressDocument + isNull: + 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: common-test + helm.sh/chart: common-test-0.1.0 + + - it: custom metadata should pass + set: + ingress.main: + enabled: true + annotations: + test_annotation: test + labels: + test_label: test + asserts: + - documentIndex: &IngressDocument 2 + 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: common-test + helm.sh/chart: common-test-0.1.0 + test_label: test + + - it: custom metadata with global metadata should pass + set: + global: + labels: + global_label: test + annotations: + global_annotation: test + ingress.main: + enabled: true + annotations: + test_annotation: test + labels: + test_label: test + asserts: + - documentIndex: &IngressDocument 2 + 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: common-test + global_label: test + helm.sh/chart: common-test-0.1.0 + test_label: test diff --git a/charts/other/kah-common-chart/tests/ingress/presence_test.yaml b/charts/other/kah-common-chart/tests/ingress/presence_test.yaml new file mode 100644 index 00000000..ace5582e --- /dev/null +++ b/charts/other/kah-common-chart/tests/ingress/presence_test.yaml @@ -0,0 +1,71 @@ +suite: ingress presence +templates: + - common.yaml +tests: + - it: default should pass + asserts: + - hasDocuments: + count: 2 + - documentIndex: 0 + not: true + isKind: + of: Ingress + - documentIndex: 1 + not: true + isKind: + of: Ingress + + - it: explicitly disabled should pass + set: + ingress.main.enabled: false + asserts: + - hasDocuments: + count: 2 + - documentIndex: 0 + not: true + isKind: + of: Ingress + - documentIndex: 1 + not: true + isKind: + of: Ingress + + - it: explicitly enabled should pass + set: + ingress.main.enabled: true + asserts: + - hasDocuments: + count: 3 + - documentIndex: 0 + not: true + isKind: + of: Ingress + - documentIndex: 1 + not: true + isKind: + of: Ingress + - documentIndex: 2 + isKind: + of: Ingress + + - it: multiple enabled should pass + set: + ingress.main.enabled: true + ingress.test.enabled: true + asserts: + - hasDocuments: + count: 4 + - documentIndex: 0 + not: true + isKind: + of: Ingress + - documentIndex: 1 + not: true + isKind: + of: Ingress + - documentIndex: 2 + isKind: + of: Ingress + - documentIndex: 3 + isKind: + of: Ingress diff --git a/charts/other/kah-common-chart/tests/ingress/service_reference_test.yaml b/charts/other/kah-common-chart/tests/ingress/service_reference_test.yaml new file mode 100644 index 00000000..2a886bad --- /dev/null +++ b/charts/other/kah-common-chart/tests/ingress/service_reference_test.yaml @@ -0,0 +1,39 @@ +suite: ingress service reference +templates: + - common.yaml +tests: + - it: default should pass + set: + ingress.main.enabled: true + asserts: + - documentIndex: &IngressDocument 2 + isKind: + of: Ingress + - documentIndex: *IngressDocument + equal: + path: spec.rules[0].http.paths[0].backend + value: + serviceName: RELEASE-NAME-common-test + servicePort: null + + - it: custom service reference should pass + set: + ingress.main: + enabled: true + hosts: + - host: chart-test.local + paths: + - path: / + service: + name: pathService + port: 1234 + asserts: + - documentIndex: &IngressDocument 2 + isKind: + of: Ingress + - documentIndex: *IngressDocument + equal: + path: spec.rules[0].http.paths[0].backend + value: + serviceName: pathService + servicePort: 1234 diff --git a/charts/other/kah-common-chart/tests/ingress/tls_test.yaml b/charts/other/kah-common-chart/tests/ingress/tls_test.yaml new file mode 100644 index 00000000..e66a002f --- /dev/null +++ b/charts/other/kah-common-chart/tests/ingress/tls_test.yaml @@ -0,0 +1,72 @@ +suite: ingress tls +templates: + - common.yaml +tests: + - it: default should pass + set: + ingress.main.enabled: true + asserts: + - documentIndex: &IngressDocument 2 + isKind: + of: Ingress + - documentIndex: *IngressDocument + isNull: + path: spec.tls + + - it: tls enabled should pass + set: + ingress.main: + enabled: true + tls: + - secretName: test + hosts: + - hostname + asserts: + - documentIndex: &IngressDocument 2 + 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: + enabled: true + tls: + - hosts: + - hostname + asserts: + - documentIndex: &IngressDocument 2 + isKind: + of: Ingress + - documentIndex: *IngressDocument + equal: + path: spec.tls[0] + value: + hosts: + - hostname + + - it: tls enabled with secret template should pass + set: + ingress.main: + enabled: true + tls: + - secretName: "{{ .Release.Name }}-secret" + hosts: + - hostname + asserts: + - documentIndex: &IngressDocument 2 + isKind: + of: Ingress + - documentIndex: *IngressDocument + equal: + path: spec.tls[0] + value: + secretName: RELEASE-NAME-secret + hosts: + - hostname diff --git a/charts/other/kah-common-chart/tests/ingress/values_test.yaml b/charts/other/kah-common-chart/tests/ingress/values_test.yaml new file mode 100644 index 00000000..ed142166 --- /dev/null +++ b/charts/other/kah-common-chart/tests/ingress/values_test.yaml @@ -0,0 +1,72 @@ +suite: ingress values +templates: + - common.yaml +tests: + - it: default should pass + set: + ingress.main.enabled: true + 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: custom host and path should pass + set: + ingress.main: + enabled: true + hosts: + - host: chart-test.local + paths: + - path: /test + 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: + enabled: true + hosts: + - host: "{{ .Release.Name }}.hostname" + 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: + enabled: true + hosts: + - host: chart-test.local + paths: + - path: "/{{ .Release.Name }}.path" + asserts: + - documentIndex: &IngressDocument 2 + isKind: + of: Ingress + - documentIndex: *IngressDocument + equal: + path: spec.rules[0].http.paths[0].path + value: "/RELEASE-NAME.path" diff --git a/charts/other/kah-common-chart/tests/persistence/claimnames_test.yaml b/charts/other/kah-common-chart/tests/persistence/claimnames_test.yaml new file mode 100644 index 00000000..81776125 --- /dev/null +++ b/charts/other/kah-common-chart/tests/persistence/claimnames_test.yaml @@ -0,0 +1,78 @@ +suite: persistence claimnames +templates: + - common.yaml +tests: + - it: default should pass + set: + persistence: + config: + enabled: true + asserts: + - documentIndex: 1 + isKind: + of: Deployment + - documentIndex: 1 + equal: + path: spec.template.spec.volumes[0] + value: + name: config + persistentVolumeClaim: + claimName: RELEASE-NAME-common-test-config + + - it: with existingClaim should pass + set: + persistence: + existingClaim: + enabled: true + 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: + enabled: true + 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-common-test + + - it: custom suffix should pass + set: + persistence: + claimWithNameOverride: + enabled: true + 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-common-test-suffix diff --git a/charts/other/kah-common-chart/tests/persistence/emptydir_test.yaml b/charts/other/kah-common-chart/tests/persistence/emptydir_test.yaml new file mode 100644 index 00000000..02cb1914 --- /dev/null +++ b/charts/other/kah-common-chart/tests/persistence/emptydir_test.yaml @@ -0,0 +1,60 @@ +suite: persistence emptydir +templates: + - common.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 diff --git a/charts/other/kah-common-chart/tests/persistence/hostpath_test.yaml b/charts/other/kah-common-chart/tests/persistence/hostpath_test.yaml new file mode 100644 index 00000000..40ce62cd --- /dev/null +++ b/charts/other/kah-common-chart/tests/persistence/hostpath_test.yaml @@ -0,0 +1,45 @@ +suite: persistence hostpath +templates: + - common.yaml +tests: + - it: hostPath should pass + set: + persistence: + hostpathmounts-data: + enabled: true + type: hostPath + hostPath: "/tmp1" + mountPath: "/data" + 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" + mountPath: "/data2" + 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 diff --git a/charts/other/kah-common-chart/tests/persistence/types_test.yaml b/charts/other/kah-common-chart/tests/persistence/types_test.yaml new file mode 100644 index 00000000..79e5678e --- /dev/null +++ b/charts/other/kah-common-chart/tests/persistence/types_test.yaml @@ -0,0 +1,127 @@ +suite: persistence types +templates: + - common.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 + + - it: configmap persistence type should pass + set: + persistence: + configmap: + enabled: true + 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: + enabled: true + type: configMap + name: "{{ include \"common.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-common-test-config + + - 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: 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 diff --git a/charts/other/kah-common-chart/tests/persistence/volumeclaimtemplates_test.yaml b/charts/other/kah-common-chart/tests/persistence/volumeclaimtemplates_test.yaml new file mode 100644 index 00000000..7efc48a4 --- /dev/null +++ b/charts/other/kah-common-chart/tests/persistence/volumeclaimtemplates_test.yaml @@ -0,0 +1,30 @@ +suite: persistence volumeclaimtemplates +templates: + - common.yaml +tests: + - it: volumeClaimTemplates should pass + set: + controller: + type: statefulset + volumeClaimTemplates: + - name: "storage" + accessMode: "ReadWriteOnce" + size: "10Gi" + storageClass: "storage" + asserts: + - documentIndex: 0 + isKind: + of: StatefulSet + - documentIndex: 0 + equal: + path: spec.volumeClaimTemplates[0] + value: + metadata: + name: storage + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Gi + storageClassName: storage diff --git a/charts/other/kah-common-chart/tests/pod/additionalcontainers_test.yaml b/charts/other/kah-common-chart/tests/pod/additionalcontainers_test.yaml new file mode 100644 index 00000000..30a1043e --- /dev/null +++ b/charts/other/kah-common-chart/tests/pod/additionalcontainers_test.yaml @@ -0,0 +1,45 @@ +suite: pod additional containers +templates: + - common.yaml +tests: + - it: with explicit name should pass + set: + additionalContainers: + additional1: + name: template-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: + additionalContainers: + additional1: + image: template-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: + additionalContainers: + additional1: + name: "{{ .Release.Name }}-container" + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[1].name + value: RELEASE-NAME-container diff --git a/charts/other/kah-common-chart/tests/pod/initcontainers_test.yaml b/charts/other/kah-common-chart/tests/pod/initcontainers_test.yaml new file mode 100644 index 00000000..fee293d5 --- /dev/null +++ b/charts/other/kah-common-chart/tests/pod/initcontainers_test.yaml @@ -0,0 +1,45 @@ +suite: pod initContainers +templates: + - common.yaml +tests: + - it: with explicit name should pass + set: + initContainers: + init1: + name: template-test + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.initContainers[0].name + value: template-test + + - it: with implicit name should pass + set: + initContainers: + init1: + image: template-test + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.initContainers[0].name + value: init1 + + - it: with templated name should pass + set: + initContainers: + init1: + name: "{{ .Release.Name }}-container" + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.initContainers[0].name + value: RELEASE-NAME-container diff --git a/charts/other/kah-common-chart/tests/pod/network_test.yaml b/charts/other/kah-common-chart/tests/pod/network_test.yaml new file mode 100644 index 00000000..a8bcd4f1 --- /dev/null +++ b/charts/other/kah-common-chart/tests/pod/network_test.yaml @@ -0,0 +1,59 @@ +suite: pod replicas +templates: + - common.yaml +tests: + - it: default should pass + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + isNull: + path: spec.template.spec.hostNetwork + - documentIndex: 0 + equal: + path: spec.template.spec.dnsPolicy + value: ClusterFirst + + - it: hostNetwork disabled should pass + set: + hostNetwork: false + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + isNull: + path: spec.template.spec.hostNetwork + - documentIndex: 0 + equal: + path: spec.template.spec.dnsPolicy + value: ClusterFirst + + - it: hostNetwork enabled should pass + set: + hostNetwork: true + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.hostNetwork + value: true + - documentIndex: 0 + equal: + path: spec.template.spec.dnsPolicy + value: ClusterFirstWithHostNet + + - it: custom dnsPolicy should pass + set: + dnsPolicy: None + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.dnsPolicy + value: None diff --git a/charts/other/kah-common-chart/tests/pod/replicas_test.yaml b/charts/other/kah-common-chart/tests/pod/replicas_test.yaml new file mode 100644 index 00000000..7e4a3793 --- /dev/null +++ b/charts/other/kah-common-chart/tests/pod/replicas_test.yaml @@ -0,0 +1,25 @@ +suite: pod replicas +templates: + - common.yaml +tests: + - it: default should pass + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.replicas + value: 1 + + - it: custom replicas should pass + set: + controller.replicas: 3 + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.replicas + value: 3 diff --git a/charts/other/kah-common-chart/tests/pvc/metadata_test.yaml b/charts/other/kah-common-chart/tests/pvc/metadata_test.yaml new file mode 100644 index 00000000..52f88f6b --- /dev/null +++ b/charts/other/kah-common-chart/tests/pvc/metadata_test.yaml @@ -0,0 +1,106 @@ +suite: pvc metadata +templates: + - common.yaml +tests: + - it: default should pass + set: + persistence.config.enabled: true + asserts: + - documentIndex: &PersistentVolumeClaimDocument 0 + isKind: + of: PersistentVolumeClaim + - documentIndex: *PersistentVolumeClaimDocument + isNull: + 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: common-test + helm.sh/chart: common-test-0.1.0 + + - it: retain enabled should pass + set: + persistence.config: + enabled: true + 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: common-test + helm.sh/chart: common-test-0.1.0 + + - it: custom metadata should pass + set: + persistence.config: + enabled: true + 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: common-test + helm.sh/chart: common-test-0.1.0 + test_label: test + + - it: custom metadata with global metadata should pass + set: + global: + labels: + global_label: test + annotations: + global_annotation: test + persistence.config: + enabled: true + 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: common-test + global_label: test + helm.sh/chart: common-test-0.1.0 + test_label: test diff --git a/charts/other/kah-common-chart/tests/pvc/names_test.yaml b/charts/other/kah-common-chart/tests/pvc/names_test.yaml new file mode 100644 index 00000000..deed6713 --- /dev/null +++ b/charts/other/kah-common-chart/tests/pvc/names_test.yaml @@ -0,0 +1,66 @@ +suite: pvc names +templates: + - common.yaml +tests: + - it: disabled should pass + asserts: + - hasDocuments: + count: 2 + - documentIndex: 0 + not: true + isKind: + of: PersistentVolumeClaim + - documentIndex: 1 + not: true + isKind: + of: PersistentVolumeClaim + + - it: default should pass + set: + persistence.config.enabled: true + asserts: + - hasDocuments: + count: 3 + - documentIndex: &PersistentVolumeClaimDocument 0 + isKind: + of: PersistentVolumeClaim + - documentIndex: 1 + not: true + isKind: + of: PersistentVolumeClaim + - documentIndex: 2 + not: true + isKind: + of: PersistentVolumeClaim + - documentIndex: *PersistentVolumeClaimDocument + equal: + path: metadata.name + value: RELEASE-NAME-common-test-config + + - it: without suffix should pass + set: + persistence.config: + enabled: true + nameOverride: "-" + asserts: + - documentIndex: &PersistentVolumeClaimDocument 0 + isKind: + of: PersistentVolumeClaim + - documentIndex: *PersistentVolumeClaimDocument + equal: + path: metadata.name + value: RELEASE-NAME-common-test + + - it: with custom suffix should pass + set: + persistence.config: + enabled: true + nameOverride: "custom" + asserts: + - documentIndex: &PersistentVolumeClaimDocument 0 + isKind: + of: PersistentVolumeClaim + - documentIndex: *PersistentVolumeClaimDocument + equal: + path: metadata.name + value: RELEASE-NAME-common-test-custom diff --git a/charts/other/kah-common-chart/tests/pvc/storageclass_test.yaml b/charts/other/kah-common-chart/tests/pvc/storageclass_test.yaml new file mode 100644 index 00000000..4b24a1ec --- /dev/null +++ b/charts/other/kah-common-chart/tests/pvc/storageclass_test.yaml @@ -0,0 +1,42 @@ +suite: pvc storageclass +templates: + - common.yaml +tests: + - it: default should pass + set: + persistence.config.enabled: true + asserts: + - documentIndex: &PersistentVolumeClaimDocument 0 + isKind: + of: PersistentVolumeClaim + - documentIndex: *PersistentVolumeClaimDocument + isNull: + path: spec.storageClassName + + - it: custom should pass + set: + persistence.config: + enabled: true + storageClass: custom + asserts: + - documentIndex: &PersistentVolumeClaimDocument 0 + isKind: + of: PersistentVolumeClaim + - documentIndex: *PersistentVolumeClaimDocument + equal: + path: spec.storageClassName + value: custom + + - it: empty should pass + set: + persistence.config: + enabled: true + storageClass: "-" + asserts: + - documentIndex: &PersistentVolumeClaimDocument 0 + isKind: + of: PersistentVolumeClaim + - documentIndex: *PersistentVolumeClaimDocument + equal: + path: spec.storageClassName + value: "" diff --git a/charts/other/kah-common-chart/tests/service/metadata_test.yaml b/charts/other/kah-common-chart/tests/service/metadata_test.yaml new file mode 100644 index 00000000..11c2311d --- /dev/null +++ b/charts/other/kah-common-chart/tests/service/metadata_test.yaml @@ -0,0 +1,81 @@ +suite: service metadata +templates: + - common.yaml +tests: + - it: default metadata should pass + asserts: + - documentIndex: &ServiceDocument 1 + isKind: + of: Service + - documentIndex: *ServiceDocument + isNull: + path: metadata.annotations + - documentIndex: *ServiceDocument + equal: + path: metadata.labels + value: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: common-test + helm.sh/chart: common-test-0.1.0 + + - it: custom metadata should pass + set: + service: + main: + annotations: + test_annotation: test + labels: + test_label: test + asserts: + - documentIndex: &ServiceDocument 1 + isKind: + of: Service + - documentIndex: *ServiceDocument + equal: + path: metadata.annotations + value: + test_annotation: test + - documentIndex: *ServiceDocument + equal: + path: metadata.labels + value: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: common-test + helm.sh/chart: common-test-0.1.0 + test_label: test + + - it: custom metadata with global metadata should pass + set: + global: + labels: + global_label: test + annotations: + global_annotation: test + service: + main: + annotations: + test_annotation: test + labels: + test_label: test + asserts: + - documentIndex: &ServiceDocument 1 + isKind: + of: Service + - documentIndex: *ServiceDocument + equal: + path: metadata.annotations + value: + global_annotation: test + test_annotation: test + - documentIndex: *ServiceDocument + equal: + path: metadata.labels + value: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: common-test + global_label: test + helm.sh/chart: common-test-0.1.0 + test_label: test diff --git a/charts/other/kah-common-chart/tests/service/names_test.yaml b/charts/other/kah-common-chart/tests/service/names_test.yaml new file mode 100644 index 00000000..3598dc6e --- /dev/null +++ b/charts/other/kah-common-chart/tests/service/names_test.yaml @@ -0,0 +1,29 @@ +suite: service names +templates: + - common.yaml +tests: + - it: default should pass + asserts: + - hasDocuments: + count: 2 + - documentIndex: &ServiceDocument 1 + isKind: + of: Service + - documentIndex: *ServiceDocument + equal: + path: metadata.name + value: RELEASE-NAME-common-test + + - it: custom name suffix should pass + set: + service: + main: + nameOverride: http + asserts: + - documentIndex: &ServiceDocument 1 + isKind: + of: Service + - documentIndex: *ServiceDocument + equal: + path: metadata.name + value: RELEASE-NAME-common-test-http diff --git a/charts/other/kah-common-chart/tests/service/port_names_test.yaml b/charts/other/kah-common-chart/tests/service/port_names_test.yaml new file mode 100644 index 00000000..fff36fe3 --- /dev/null +++ b/charts/other/kah-common-chart/tests/service/port_names_test.yaml @@ -0,0 +1,63 @@ +suite: service port names +templates: + - common.yaml +tests: + - it: default should pass + asserts: + - hasDocuments: + count: 2 + - documentIndex: &ServiceDocument 1 + isKind: + of: Service + - documentIndex: *ServiceDocument + equal: + path: spec.ports[0] + value: + name: http + port: null + protocol: TCP + targetPort: http + + - it: custom name should pass + set: + service: + main: + ports: + http: + enabled: false + server: + enabled: true + port: 8080 + asserts: + - documentIndex: &ServiceDocument 1 + isKind: + of: Service + - documentIndex: *ServiceDocument + equal: + path: spec.ports[0] + value: + name: server + port: 8080 + protocol: TCP + targetPort: server + + - it: custom target port should pass + set: + service: + main: + ports: + http: + enabled: true + targetPort: 80 + asserts: + - documentIndex: &ServiceDocument 1 + isKind: + of: Service + - documentIndex: *ServiceDocument + equal: + path: spec.ports[0] + value: + name: http + port: null + protocol: TCP + targetPort: 80 diff --git a/charts/other/kah-common-chart/tests/service/port_protocols_test.yaml b/charts/other/kah-common-chart/tests/service/port_protocols_test.yaml new file mode 100644 index 00000000..6db69bea --- /dev/null +++ b/charts/other/kah-common-chart/tests/service/port_protocols_test.yaml @@ -0,0 +1,71 @@ +suite: service protocols +templates: + - common.yaml +tests: + - it: default should pass + asserts: + - hasDocuments: + count: 2 + - documentIndex: &ServiceDocument 1 + isKind: + of: Service + - documentIndex: *ServiceDocument + equal: + path: spec.ports[0].protocol + value: TCP + + - it: explicit TCP should pass + set: + service.main.ports.http.protocol: TCP + asserts: + - documentIndex: &ServiceDocument 1 + isKind: + of: Service + - documentIndex: *ServiceDocument + equal: + path: spec.ports[0].protocol + value: TCP + + - it: explicit UDP should pass + set: + service.main.ports.http.protocol: UDP + asserts: + - documentIndex: &ServiceDocument 1 + isKind: + of: Service + - documentIndex: *ServiceDocument + equal: + path: spec.ports[0].protocol + value: UDP + + - it: explicit HTTP should pass + set: + service.main.ports.http.protocol: HTTP + asserts: + - documentIndex: &ServiceDocument 1 + isKind: + of: Service + - documentIndex: *ServiceDocument + equal: + path: spec.ports[0].protocol + value: TCP + - documentIndex: *ServiceDocument + isNull: + path: metadata.annotations + + - it: explicit HTTPS should pass + set: + service.main.ports.http.protocol: HTTPS + asserts: + - documentIndex: &ServiceDocument 1 + isKind: + of: Service + - documentIndex: *ServiceDocument + equal: + path: spec.ports[0].protocol + value: TCP + - documentIndex: *ServiceDocument + equal: + path: metadata.annotations + value: + traefik.ingress.kubernetes.io/service.serversscheme: https diff --git a/charts/other/kah-common-chart/tests/service/values_test.yaml b/charts/other/kah-common-chart/tests/service/values_test.yaml new file mode 100644 index 00000000..b7edd82f --- /dev/null +++ b/charts/other/kah-common-chart/tests/service/values_test.yaml @@ -0,0 +1,33 @@ +suite: service values +templates: + - common.yaml +tests: + - it: externalTrafficPolicy should pass for NodePort service + set: + service: + main: + type: NodePort + externalTrafficPolicy: Local + asserts: + - documentIndex: &ServiceDocument 1 + isKind: + of: Service + - documentIndex: *ServiceDocument + equal: + path: spec.externalTrafficPolicy + value: Local + + - it: externalTrafficPolicy should pass for LoadBalancer service + set: + service: + main: + type: LoadBalancer + externalTrafficPolicy: Local + asserts: + - documentIndex: &ServiceDocument 1 + isKind: + of: Service + - documentIndex: *ServiceDocument + equal: + path: spec.externalTrafficPolicy + value: Local diff --git a/charts/other/kah-common-chart/values.yaml b/charts/other/kah-common-chart/values.yaml new file mode 100644 index 00000000..ed97d539 --- /dev/null +++ b/charts/other/kah-common-chart/values.yaml @@ -0,0 +1 @@ +---