fix(common): always force a rename and recreate of cert-secrets on update (#1422)

* fix(common): always force a rename and recreate of cert-secrets on update

* hmm

* adapt tests
This commit is contained in:
Kjeld Schouten-Lebbing 2021-11-30 00:49:16 +01:00 committed by GitHub
parent 70df160dd3
commit daee087f81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 10 deletions

View File

@ -15,4 +15,4 @@ maintainers:
name: common
sources: null
type: library
version: 8.9.4
version: 8.9.5

View File

@ -85,7 +85,7 @@ spec:
- {{ tpl . $ | quote }}
{{- end }}
{{- if $tlsValues.scaleCert }}
secretName: {{ ( printf "%v-%v-%v-%v-%v" $ingressName "tls" $index "ixcert" $tlsValues.scaleCert ) }}
secretName: {{ ( printf "%v-%v-%v-%v-%v-%v" $ingressName "tls" $index "ixcert" $tlsValues.scaleCert $.Release.Revision ) }}
{{- else if .secretName }}
secretName: {{ tpl .secretName $ | quote}}
{{- end }}

View File

@ -20,7 +20,7 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ $secretName }}
name: {{ $secretName }}-{{ .Release.Revision }}
labels: {{ include "common.labels" . | nindent 4 }}
type: kubernetes.io/tls
data:

View File

@ -88,7 +88,7 @@ class Test < ChartTest
chart.value values
refute_nil(resource('Secret'))
secret = chart.resources(kind: "Secret").first
assert_equal("common-test-tls-0-ixcert-1", secret["metadata"]["name"])
assert_equal("common-test-tls-0-ixcert-1-1", secret["metadata"]["name"])
refute_nil(secret["data"]["tls.crt"])
refute_nil(secret["data"]["tls.key"])
end
@ -166,13 +166,13 @@ class Test < ChartTest
chart.value values
refute_nil(resource('Secret'))
secret = chart.resources(kind: "Secret").first
assert_equal("common-test-tls-0-ixcert-1", secret["metadata"]["name"])
assert_equal("common-test-tls-0-ixcert-1-1", secret["metadata"]["name"])
refute_nil(secret["data"]["tls.crt"])
refute_nil(secret["data"]["tls.key"])
ingress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(ingress)
assert_equal("common-test-tls-0-ixcert-1", ingress["spec"]["tls"][0]["secretName"])
assert_equal("common-test-tls-0-ixcert-1-1", ingress["spec"]["tls"][0]["secretName"])
end
it 'multiple tls sections generate multiple secrets' do
values = {
@ -304,18 +304,18 @@ class Test < ChartTest
chart.value values
refute_nil(resource('Secret'))
secret1 = chart.resources(kind: "Secret").first
assert_equal("common-test-tls-0-ixcert-1", secret1["metadata"]["name"])
assert_equal("common-test-tls-0-ixcert-1-1", secret1["metadata"]["name"])
refute_nil(secret1["data"]["tls.crt"])
refute_nil(secret1["data"]["tls.key"])
secret2 = chart.resources(kind: "Secret").find{ |s| s["metadata"]["name"] == "common-test-tls-1-ixcert-2" }
secret2 = chart.resources(kind: "Secret").find{ |s| s["metadata"]["name"] == "common-test-tls-1-ixcert-2-1" }
refute_nil(secret2)
refute_nil(secret2["data"]["tls.crt"])
refute_nil(secret2["data"]["tls.key"])
ingress = chart.resources(kind: "Ingress").find{ |s| s["metadata"]["name"] == "common-test" }
refute_nil(ingress)
assert_equal("common-test-tls-0-ixcert-1", ingress["spec"]["tls"][0]["secretName"])
assert_equal("common-test-tls-1-ixcert-2", ingress["spec"]["tls"][1]["secretName"])
assert_equal("common-test-tls-0-ixcert-1-1", ingress["spec"]["tls"][0]["secretName"])
assert_equal("common-test-tls-1-ixcert-2-1", ingress["spec"]["tls"][1]["secretName"])
end
end
end