From 9be8240c956066b56e2ed1809e46e6d051f78bc1 Mon Sep 17 00:00:00 2001 From: Matt Rogers Date: Mon, 15 Jul 2024 13:33:27 +0100 Subject: [PATCH] fix: handle leading/trailing whitespace --- charts/snyk-broker/templates/secrets.yaml | 2 +- .../snyk-broker/tests/broker_deployment_ca_test.yaml | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/charts/snyk-broker/templates/secrets.yaml b/charts/snyk-broker/templates/secrets.yaml index 70ee86e..2ff6dba 100644 --- a/charts/snyk-broker/templates/secrets.yaml +++ b/charts/snyk-broker/templates/secrets.yaml @@ -184,7 +184,7 @@ data: {{- if and .Values.caCert (not .Values.caCertFile) }} {{ (.Files.Glob .Values.caCert).AsSecrets | nindent 2 }} {{- else if and .Values.caCertFile (not .Values.caCert) }} - cacert: {{ .Values.caCertFile | b64enc | nindent 4}} + cacert: {{ .Values.caCertFile | trim | b64enc | nindent 4}} {{- end }} --- {{- end }} diff --git a/charts/snyk-broker/tests/broker_deployment_ca_test.yaml b/charts/snyk-broker/tests/broker_deployment_ca_test.yaml index 6a8aa3b..6df9315 100644 --- a/charts/snyk-broker/tests/broker_deployment_ca_test.yaml +++ b/charts/snyk-broker/tests/broker_deployment_ca_test.yaml @@ -253,3 +253,15 @@ tests: documentSelector: path: metadata.name value: RELEASE-NAME-snyk-broker-cacert-secret + + - it: handles extra whitespace + set: + caCertFile: "\n \n-----BEGIN CERTIFICATE-----\nCERTIFICATE GOES HERE\n-----END CERTIFICATE-----\n\n\n" + asserts: + - equal: + path: data.cacert + value: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCkNFUlRJRklDQVRFIEdPRVMgSEVSRQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0t + template: secrets.yaml + documentSelector: + path: metadata.name + value: RELEASE-NAME-snyk-broker-cacert-secret