diff --git a/charts/external-dns/CHANGELOG.md b/charts/external-dns/CHANGELOG.md index 3a4552209..6882ce29c 100644 --- a/charts/external-dns/CHANGELOG.md +++ b/charts/external-dns/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Correctly handles 'txtPrefix' and 'txtSuffix' arguments when both are provided. ([#5250](https://github.com/kubernetes-sigs/external-dns/pull/5250)) _@ivankatliarchuk_ - Add missing types in the schema for empty values ([#5228](https://github.com/kubernetes-sigs/external-dns/pull/5228)) _@ivankatliarchuk_ - Add missing types in the schema for empty values ([#5207](https://github.com/kubernetes-sigs/external-dns/pull/5207)) _@t3mi_ diff --git a/charts/external-dns/templates/deployment.yaml b/charts/external-dns/templates/deployment.yaml index ae60cffcf..7a1ec8c72 100644 --- a/charts/external-dns/templates/deployment.yaml +++ b/charts/external-dns/templates/deployment.yaml @@ -100,10 +100,12 @@ spec: {{- if .Values.txtOwnerId }} - --txt-owner-id={{ .Values.txtOwnerId }} {{- end }} + {{- if and .Values.txtPrefix .Values.txtSuffix }} + {{- fail (printf "'txtPrefix' and 'txtSuffix' are mutually exclusive") }} + {{- end }} {{- if .Values.txtPrefix }} - --txt-prefix={{ .Values.txtPrefix }} - {{- end }} - {{- if and (eq .Values.txtPrefix "") (ne .Values.txtSuffix "") }} + {{- else if .Values.txtSuffix }} - --txt-suffix={{ .Values.txtSuffix }} {{- end }} {{- if .Values.namespaced }} diff --git a/charts/external-dns/tests/deployment-flags_test.yaml b/charts/external-dns/tests/deployment-flags_test.yaml index 38a9567ff..44ae176c3 100644 --- a/charts/external-dns/tests/deployment-flags_test.yaml +++ b/charts/external-dns/tests/deployment-flags_test.yaml @@ -6,7 +6,6 @@ release: tests: - it: should provide expected default flags asserts: - # - matchSnapshot: {} - exists : path: spec.template.spec.containers[?(@.name == "external-dns")] - equal : @@ -21,33 +20,6 @@ tests: - --registry=txt - --provider=aws - - it: should configure txtPrefix and ignore txtSuffix if not empty - set: - provider: - name: cloudflare - txtPrefix: "test-prefix" - txtSuffix: "test-suffix" - txtOwnerId: "testing" - asserts: - - exists : - path: spec.template.spec.containers[?(@.name == "external-dns")] - - equal : - path: spec.template.spec.containers[?(@.name == "external-dns")].args - value: - - --log-level=info - - --log-format=text - - --interval=1m - - --source=service - - --source=ingress - - --policy=upsert-only - - --registry=txt - - --txt-owner-id=testing - - --txt-prefix=test-prefix - - --provider=cloudflare - - notContains: - path: spec.template.spec.containers[?(@.name == "external-dns")].args - content: "--txt-suffix=test-suffix" - - it: should configure 'txtSuffix' when not empty with 'txtPrefix' empty set: txtPrefix: "" @@ -70,6 +42,19 @@ tests: - notContains: path: spec.template.spec.containers[?(@.name == "external-dns")].args content: "--txt-prefix=test-prefix" + - contains: + path: spec.template.spec.containers[?(@.name == "external-dns")].args + content: "--txt-suffix=test-suffix" + + - it: should configure 'txtSuffix' when set and 'txtPrefix' is not present + set: + txtSuffix: "custom-suffix" + asserts: + - exists : + path: spec.template.spec.containers[?(@.name == "external-dns")] + - contains: + path: spec.template.spec.containers[?(@.name == "external-dns")].args + content: "--txt-suffix=custom-suffix" - it: should be able configure multiple sources set: @@ -117,3 +102,11 @@ tests: - --zone-id-filter=/hostedzone/Z00003 - --zone-id-filter=/hostedzone/Z00004 - --zone-id-filter=/hostedzone/Z00005 + + - it: should throw error when txtPrefix and txtSuffix are set + set: + txtPrefix: "test-prefix" + txtSuffix: "test-suffix" + asserts: + - failedTemplate: + errorMessage: "'txtPrefix' and 'txtSuffix' are mutually exclusive"