Skip to content

Commit 3602239

Browse files
committed
Fix var usage in Ingress with ingress.hosts
and fix tests
1 parent f168716 commit 3602239

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

templates/ingress.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ spec:
2424
paths:
2525
{{- range .paths }}
2626
- path: {{ default "/*" .path }}
27-
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1" }}
27+
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1" }}
2828
pathType: Prefix
2929
backend:
3030
service:

tests/unit/ingress_test.yaml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,21 @@ tests:
1212
asserts:
1313
- hasDocuments:
1414
count: 0
15-
15+
1616
- it: Ingress is present when enabled without hosts (older k8s)
17-
capabilities:
17+
capabilities: &cap_older
1818
majorVersion: 1
1919
minorVersion: 18
20+
apiVersions:
21+
- networking.k8s.io/v1beta1
2022
set:
2123
ingress:
2224
enabled: true
2325
hosts: []
2426
tls: []
2527
st2web:
2628
service:
27-
hostname: &st2web_hostname some-host-name
29+
hostname: &st2web_hostname hostname.domain.tld
2830
release:
2931
name: st2ha
3032
asserts:
@@ -49,18 +51,20 @@ tests:
4951
path: spec.rules[0].http.paths[0].pathType
5052

5153
- it: Ingress is present when enabled without hosts (newer k8s)
52-
capabilities:
53-
# introduced in 1.19, stable in 1.22
54+
capabilities: &cap_newer
5455
majorVersion: 1
5556
minorVersion: 19
57+
apiVersions:
58+
- networking.k8s.io/v1 # introduced in 1.19, stable in 1.22
59+
- networking.k8s.io/v1beta1
5660
set:
5761
ingress:
5862
enabled: true
5963
hosts: []
6064
tls: []
6165
st2web:
6266
service:
63-
hostname: some-host-name
67+
hostname: *st2web_hostname
6468
release:
6569
name: st2ha
6670
asserts:
@@ -84,14 +88,12 @@ tests:
8488
number: 80
8589

8690
- it: Ingress is present when enabled with hosts (older k8s)
87-
capabilities:
88-
majorVersion: 1
89-
minorVersion: 18
91+
capabilities: *cap_older
9092
set:
9193
ingress:
9294
enabled: true
9395
hosts: &hosts
94-
- host: hostname.domain.tld
96+
- host: *st2web_hostname
9597
paths:
9698
- serviceName: st2ha-st2web
9799
servicePort: 80
@@ -135,18 +137,15 @@ tests:
135137
servicePort: 8080
136138

137139
- it: Ingress is present when enabled with hosts (newer k8s)
138-
capabilities:
139-
# introduced in 1.19, stable in 1.22
140-
majorVersion: 1
141-
minorVersion: 19
140+
capabilities: *cap_newer
142141
set:
143142
ingress:
144143
enabled: true
145144
hosts: *hosts
146145
tls: []
147146
st2web:
148147
service:
149-
hostname: some-host-name
148+
hostname: *st2web_hostname
150149
release:
151150
name: st2ha
152151
asserts:
@@ -160,7 +159,7 @@ tests:
160159
- equal: *host_path_is_root_glob
161160
- equal:
162161
path: spec.rules[0].http.paths[0].pathType
163-
value: Preix
162+
value: Prefix
164163
- equal:
165164
path: spec.rules[0].http.paths[0].backend
166165
value:
@@ -174,7 +173,7 @@ tests:
174173
value: "/fancy-sensor"
175174
- equal:
176175
path: spec.rules[0].http.paths[1].pathType
177-
value: Preix
176+
value: Prefix
178177
- equal:
179178
path: spec.rules[0].http.paths[1].backend
180179
value:

0 commit comments

Comments
 (0)