chore(helm): add validation for prefix and suffix and capture regression (#5250)

* chore(helm): add valiation.tpl and capture regression

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>

* chore(helm): add valiation.tpl and capture regression

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>

* chore(helm): add validation.tpl and capture regression

Co-authored-by: Michel Loiseleur <97035654+mloiseleur@users.noreply.github.com>

* chore(helm): add validation.tpl and capture regression

Co-authored-by: Michel Loiseleur <97035654+mloiseleur@users.noreply.github.com>

* chore(helm): add validation.tpl and capture regression

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>

* chore(helm): add validation.tpl and capture regression

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>

* chore(helm): add validation for prefix and suffix and capture regression

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>

* chore(helm): add validation for prefix and suffix and capture regression

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>

* chore(helm): add validation for prefix and suffix and capture regression

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>

* chore(helm): add validation for prefix and suffix and capture regression

Co-authored-by: Steve Hipwell <steve.hipwell@gmail.com>

---------

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Co-authored-by: Michel Loiseleur <97035654+mloiseleur@users.noreply.github.com>
Co-authored-by: Steve Hipwell <steve.hipwell@gmail.com>
This commit is contained in:
Ivan Ka 2025-04-08 20:14:49 +01:00 committed by GitHub
parent cf9ab7be8b
commit 5eeef23b1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 30 deletions

View File

@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### 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 ([#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_ - Add missing types in the schema for empty values ([#5207](https://github.com/kubernetes-sigs/external-dns/pull/5207)) _@t3mi_

View File

@ -100,10 +100,12 @@ spec:
{{- if .Values.txtOwnerId }} {{- if .Values.txtOwnerId }}
- --txt-owner-id={{ .Values.txtOwnerId }} - --txt-owner-id={{ .Values.txtOwnerId }}
{{- end }} {{- end }}
{{- if and .Values.txtPrefix .Values.txtSuffix }}
{{- fail (printf "'txtPrefix' and 'txtSuffix' are mutually exclusive") }}
{{- end }}
{{- if .Values.txtPrefix }} {{- if .Values.txtPrefix }}
- --txt-prefix={{ .Values.txtPrefix }} - --txt-prefix={{ .Values.txtPrefix }}
{{- end }} {{- else if .Values.txtSuffix }}
{{- if and (eq .Values.txtPrefix "") (ne .Values.txtSuffix "") }}
- --txt-suffix={{ .Values.txtSuffix }} - --txt-suffix={{ .Values.txtSuffix }}
{{- end }} {{- end }}
{{- if .Values.namespaced }} {{- if .Values.namespaced }}

View File

@ -6,7 +6,6 @@ release:
tests: tests:
- it: should provide expected default flags - it: should provide expected default flags
asserts: asserts:
# - matchSnapshot: {}
- exists : - exists :
path: spec.template.spec.containers[?(@.name == "external-dns")] path: spec.template.spec.containers[?(@.name == "external-dns")]
- equal : - equal :
@ -21,33 +20,6 @@ tests:
- --registry=txt - --registry=txt
- --provider=aws - --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 - it: should configure 'txtSuffix' when not empty with 'txtPrefix' empty
set: set:
txtPrefix: "" txtPrefix: ""
@ -70,6 +42,19 @@ tests:
- notContains: - notContains:
path: spec.template.spec.containers[?(@.name == "external-dns")].args path: spec.template.spec.containers[?(@.name == "external-dns")].args
content: "--txt-prefix=test-prefix" 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 - it: should be able configure multiple sources
set: set:
@ -117,3 +102,11 @@ tests:
- --zone-id-filter=/hostedzone/Z00003 - --zone-id-filter=/hostedzone/Z00003
- --zone-id-filter=/hostedzone/Z00004 - --zone-id-filter=/hostedzone/Z00004
- --zone-id-filter=/hostedzone/Z00005 - --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"