From a3af9d12875baa3a7f38da40d168cbea6e23674f Mon Sep 17 00:00:00 2001 From: Michal Kuratczyk Date: Wed, 25 Nov 2020 17:15:49 +0100 Subject: [PATCH] Add missing chart properties Add a test to check if there are CRD properties not exposed by the chart --- charts/rabbitmq/.gitignore | 2 ++ charts/rabbitmq/Chart.yaml | 10 +++++----- charts/rabbitmq/example-configurations.yaml | 9 ++++++++- charts/rabbitmq/expected-template-output | 7 ++++++- charts/rabbitmq/templates/rabbitmq.yaml | 19 +++++++++++++++++-- charts/rabbitmq/test.sh | 18 +++++++++++++----- 6 files changed, 51 insertions(+), 14 deletions(-) create mode 100644 charts/rabbitmq/.gitignore diff --git a/charts/rabbitmq/.gitignore b/charts/rabbitmq/.gitignore new file mode 100644 index 000000000..15681324c --- /dev/null +++ b/charts/rabbitmq/.gitignore @@ -0,0 +1,2 @@ +rabbitmq-*.tgz +template-output diff --git a/charts/rabbitmq/Chart.yaml b/charts/rabbitmq/Chart.yaml index 1f375f535..e2abee5c6 100644 --- a/charts/rabbitmq/Chart.yaml +++ b/charts/rabbitmq/Chart.yaml @@ -10,12 +10,12 @@ name: rabbitmq description: RabbitMQ Cluster apiVersion: v2 -version: 0.8.0 +version: 0.9.0 appVersion: 3.8.9 keywords: -- rabbitmq -- message queue -- AMQP -home: https://www.rabbitmq.com + - rabbitmq + - message queue + - AMQP +home: https://www.rabbitmq.com icon: https://www.rabbitmq.com/img/rabbitmq_logo_strap.png engine: gotpl diff --git a/charts/rabbitmq/example-configurations.yaml b/charts/rabbitmq/example-configurations.yaml index dd0868eb3..7255c1747 100644 --- a/charts/rabbitmq/example-configurations.yaml +++ b/charts/rabbitmq/example-configurations.yaml @@ -19,7 +19,8 @@ replicas: 3 image: "rabbitmq:3.8.9-management" -imagePullSecret: foo +imagePullSecrets: + - name: foo service: type: LoadBalancer @@ -73,6 +74,12 @@ affinity: tls: secretName: tls-secret + caSecretName: tls-ca-secret + disableNonTLSListeners: true + +terminationGracePeriodSeconds: 42 + +skipPostDeploySteps: true override: statefulSet: diff --git a/charts/rabbitmq/expected-template-output b/charts/rabbitmq/expected-template-output index a893cbfa5..aab761ab8 100644 --- a/charts/rabbitmq/expected-template-output +++ b/charts/rabbitmq/expected-template-output @@ -21,7 +21,8 @@ metadata: spec: image: rabbitmq:3.8.9-management - imagePullSecret: foo + imagePullSecrets: + - name: foo replicas: 3 service: type: LoadBalancer @@ -72,6 +73,8 @@ spec: ]. tls: secretName: tls-secret + caSecretName: tls-ca-secret + disableNonTLSListeners: true override: statefulSet: spec: @@ -83,3 +86,5 @@ spec: - containerPort: 12345 name: additional-port protocol: TCP + skipPostDeploySteps: true + terminationGracePeriodSeconds: 42 diff --git a/charts/rabbitmq/templates/rabbitmq.yaml b/charts/rabbitmq/templates/rabbitmq.yaml index a576dce4f..c918c771f 100644 --- a/charts/rabbitmq/templates/rabbitmq.yaml +++ b/charts/rabbitmq/templates/rabbitmq.yaml @@ -26,8 +26,9 @@ spec: image: {{ .Values.image }} {{- end }} - {{- if .Values.imagePullSecret }} - imagePullSecret: {{ .Values.imagePullSecret }} + {{- if .Values.imagePullSecrets }} + imagePullSecrets: +{{ toYaml .Values.imagePullSecrets | indent 2 }} {{- end }} {{- if .Values.replicas }} @@ -98,9 +99,23 @@ spec: {{- if .Values.tls.secretName }} secretName: {{ .Values.tls.secretName }} {{- end }} + {{- if .Values.tls.caSecretName }} + caSecretName: {{ .Values.tls.caSecretName }} + {{- end }} + {{- if .Values.tls.disableNonTLSListeners }} + disableNonTLSListeners: {{ .Values.tls.disableNonTLSListeners }} + {{- end }} {{- end }} {{- if .Values.override }} override: {{ toYaml .Values.override | indent 4 }} {{- end }} + + {{- if .Values.skipPostDeploySteps }} + skipPostDeploySteps: {{ toYaml .Values.skipPostDeploySteps }} + {{- end }} + + {{- if .Values.terminationGracePeriodSeconds }} + terminationGracePeriodSeconds: {{ toYaml .Values.terminationGracePeriodSeconds }} + {{- end }} diff --git a/charts/rabbitmq/test.sh b/charts/rabbitmq/test.sh index fd400abc5..906c2fff3 100755 --- a/charts/rabbitmq/test.sh +++ b/charts/rabbitmq/test.sh @@ -8,12 +8,20 @@ # # This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file. -set -ex +set -e -helm package . +for p in $(kubectl eg rabbitmqclusters.rabbitmq.com | yq d - spec.resources | yq d - spec.tolerations | yq d - spec.override | yq d - spec.affinity | yq r - spec | grep -v ' - ' | awk -F: '{ print $1 }'); do + grep -q "$p " templates/rabbitmq.yaml + if [[ $? != 0 ]]; then + echo "FAIL: Property $p not exposed in the helm chart" + exit 1 + fi + done +echo "Seems like all CRD properties are exposed in the helm chart" -helm template rabbitmq-0.8.0.tgz -f example-configurations.yaml > template-output +chart=$(helm package . | helm package . | awk '{print $NF}') + +helm template $chart -f example-configurations.yaml > template-output -# expected-template-output is generated by running helm template rabbitmq-0.1.tgz -f plans/example-configurations.yaml > expected-template-output # it should be updated if we add any new configurations and when we modify plans/example-configurations.yaml -diff template-output expected-template-output +diff -u template-output expected-template-output && echo "Successfully rendered the template"