Skip to content

Commit 5eeef23

Browse files
ivankatliarchukmloiseleurstevehipwell
authored
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 <[email protected]> * chore(helm): add valiation.tpl and capture regression Signed-off-by: ivan katliarchuk <[email protected]> * chore(helm): add validation.tpl and capture regression Co-authored-by: Michel Loiseleur <[email protected]> * chore(helm): add validation.tpl and capture regression Co-authored-by: Michel Loiseleur <[email protected]> * chore(helm): add validation.tpl and capture regression Signed-off-by: ivan katliarchuk <[email protected]> * chore(helm): add validation.tpl and capture regression Signed-off-by: ivan katliarchuk <[email protected]> * chore(helm): add validation for prefix and suffix and capture regression Signed-off-by: ivan katliarchuk <[email protected]> * chore(helm): add validation for prefix and suffix and capture regression Signed-off-by: ivan katliarchuk <[email protected]> * chore(helm): add validation for prefix and suffix and capture regression Signed-off-by: ivan katliarchuk <[email protected]> * chore(helm): add validation for prefix and suffix and capture regression Co-authored-by: Steve Hipwell <[email protected]> --------- Signed-off-by: ivan katliarchuk <[email protected]> Co-authored-by: Michel Loiseleur <[email protected]> Co-authored-by: Steve Hipwell <[email protected]>
1 parent cf9ab7b commit 5eeef23

File tree

3 files changed

+24
-28
lines changed

3 files changed

+24
-28
lines changed

charts/external-dns/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424

2525
### Fixed
2626

27+
- Correctly handles 'txtPrefix' and 'txtSuffix' arguments when both are provided. ([#5250](https://github.com/kubernetes-sigs/external-dns/pull/5250)) _@ivankatliarchuk_
2728
- Add missing types in the schema for empty values ([#5228](https://github.com/kubernetes-sigs/external-dns/pull/5228)) _@ivankatliarchuk_
2829
- Add missing types in the schema for empty values ([#5207](https://github.com/kubernetes-sigs/external-dns/pull/5207)) _@t3mi_
2930

charts/external-dns/templates/deployment.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,12 @@ spec:
100100
{{- if .Values.txtOwnerId }}
101101
- --txt-owner-id={{ .Values.txtOwnerId }}
102102
{{- end }}
103+
{{- if and .Values.txtPrefix .Values.txtSuffix }}
104+
{{- fail (printf "'txtPrefix' and 'txtSuffix' are mutually exclusive") }}
105+
{{- end }}
103106
{{- if .Values.txtPrefix }}
104107
- --txt-prefix={{ .Values.txtPrefix }}
105-
{{- end }}
106-
{{- if and (eq .Values.txtPrefix "") (ne .Values.txtSuffix "") }}
108+
{{- else if .Values.txtSuffix }}
107109
- --txt-suffix={{ .Values.txtSuffix }}
108110
{{- end }}
109111
{{- if .Values.namespaced }}

charts/external-dns/tests/deployment-flags_test.yaml

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ release:
66
tests:
77
- it: should provide expected default flags
88
asserts:
9-
# - matchSnapshot: {}
109
- exists :
1110
path: spec.template.spec.containers[?(@.name == "external-dns")]
1211
- equal :
@@ -21,13 +20,10 @@ tests:
2120
- --registry=txt
2221
- --provider=aws
2322

24-
- it: should configure txtPrefix and ignore txtSuffix if not empty
23+
- it: should configure 'txtSuffix' when not empty with 'txtPrefix' empty
2524
set:
26-
provider:
27-
name: cloudflare
28-
txtPrefix: "test-prefix"
25+
txtPrefix: ""
2926
txtSuffix: "test-suffix"
30-
txtOwnerId: "testing"
3127
asserts:
3228
- exists :
3329
path: spec.template.spec.containers[?(@.name == "external-dns")]
@@ -41,35 +37,24 @@ tests:
4137
- --source=ingress
4238
- --policy=upsert-only
4339
- --registry=txt
44-
- --txt-owner-id=testing
45-
- --txt-prefix=test-prefix
46-
- --provider=cloudflare
40+
- --txt-suffix=test-suffix
41+
- --provider=aws
4742
- notContains:
43+
path: spec.template.spec.containers[?(@.name == "external-dns")].args
44+
content: "--txt-prefix=test-prefix"
45+
- contains:
4846
path: spec.template.spec.containers[?(@.name == "external-dns")].args
4947
content: "--txt-suffix=test-suffix"
5048

51-
- it: should configure 'txtSuffix' when not empty with 'txtPrefix' empty
49+
- it: should configure 'txtSuffix' when set and 'txtPrefix' is not present
5250
set:
53-
txtPrefix: ""
54-
txtSuffix: "test-suffix"
51+
txtSuffix: "custom-suffix"
5552
asserts:
5653
- exists :
5754
path: spec.template.spec.containers[?(@.name == "external-dns")]
58-
- equal :
59-
path: spec.template.spec.containers[?(@.name == "external-dns")].args
60-
value:
61-
- --log-level=info
62-
- --log-format=text
63-
- --interval=1m
64-
- --source=service
65-
- --source=ingress
66-
- --policy=upsert-only
67-
- --registry=txt
68-
- --txt-suffix=test-suffix
69-
- --provider=aws
70-
- notContains:
55+
- contains:
7156
path: spec.template.spec.containers[?(@.name == "external-dns")].args
72-
content: "--txt-prefix=test-prefix"
57+
content: "--txt-suffix=custom-suffix"
7358

7459
- it: should be able configure multiple sources
7560
set:
@@ -117,3 +102,11 @@ tests:
117102
- --zone-id-filter=/hostedzone/Z00003
118103
- --zone-id-filter=/hostedzone/Z00004
119104
- --zone-id-filter=/hostedzone/Z00005
105+
106+
- it: should throw error when txtPrefix and txtSuffix are set
107+
set:
108+
txtPrefix: "test-prefix"
109+
txtSuffix: "test-suffix"
110+
asserts:
111+
- failedTemplate:
112+
errorMessage: "'txtPrefix' and 'txtSuffix' are mutually exclusive"

0 commit comments

Comments
 (0)