@@ -152,6 +152,27 @@ func TestExecuteTemplate_ForMergeableIngressForNGINXPlus(t *testing.T) {
152
152
}
153
153
}
154
154
155
+ func TestExecuteTemplate_ForMergeableIngressForNGINXPlusWithMasterPathRegex (t * testing.T ) {
156
+ t .Parallel ()
157
+
158
+ tmpl := newNGINXPlusIngressTmpl (t )
159
+ buf := & bytes.Buffer {}
160
+
161
+ err := tmpl .Execute (buf , ingressCfgMasterMinionNGINXPlusMasterMinions )
162
+ t .Log (buf .String ())
163
+ if err != nil {
164
+ t .Fatal (err )
165
+ }
166
+ want := "location /coffee {"
167
+ if ! strings .Contains (buf .String (), want ) {
168
+ t .Errorf ("want %q in generated config" , want )
169
+ }
170
+ want = "location /tea {"
171
+ if ! strings .Contains (buf .String (), want ) {
172
+ t .Errorf ("want %q in generated config" , want )
173
+ }
174
+ }
175
+
155
176
func TestExecuteTemplate_ForMergeableIngressWithOneMinionWithPathRegexAnnotation (t * testing.T ) {
156
177
t .Parallel ()
157
178
@@ -210,11 +231,11 @@ func TestExecuteTemplate_ForMergeableIngressForNGINXPlusWithPathRegexAnnotationO
210
231
t .Fatal (err )
211
232
}
212
233
213
- want := "location ~ \" ^ /coffee\" {"
234
+ want := "location /coffee {"
214
235
if ! strings .Contains (buf .String (), want ) {
215
236
t .Errorf ("want %q in generated config" , want )
216
237
}
217
- want = "location ~ \" ^ /tea\" {"
238
+ want = "location /tea {"
218
239
if ! strings .Contains (buf .String (), want ) {
219
240
t .Errorf ("want %q in generated config" , want )
220
241
}
@@ -915,6 +936,80 @@ var (
915
936
},
916
937
}
917
938
939
+ // ingressCfgMasterMinionNGINXPlusMasterMinions holds data to test the following scenario:
940
+ //
941
+ // Ingress Master - Minion
942
+ // - Master: with `path-regex` annotation
943
+ // - Minion 1 (cafe-ingress-coffee-minion): without `path-regex` annotation
944
+ // - Minion 2 (cafe-ingress-tea-minion): without `path-regex` annotation
945
+ ingressCfgMasterMinionNGINXPlusMasterMinions = IngressNginxConfig {
946
+ Upstreams : []Upstream {
947
+ coffeeUpstreamNginxPlus ,
948
+ teaUpstreamNGINXPlus ,
949
+ },
950
+ Servers : []Server {
951
+ {
952
+ Name : "cafe.example.com" ,
953
+ ServerTokens : "on" ,
954
+ Locations : []Location {
955
+ {
956
+ Path : "/coffee" ,
957
+ ServiceName : "coffee-svc" ,
958
+ Upstream : coffeeUpstreamNginxPlus ,
959
+ ProxyConnectTimeout : "60s" ,
960
+ ProxyReadTimeout : "60s" ,
961
+ ProxySendTimeout : "60s" ,
962
+ ClientMaxBodySize : "1m" ,
963
+ ProxyBuffering : true ,
964
+ MinionIngress : & Ingress {
965
+ Name : "cafe-ingress-coffee-minion" ,
966
+ Namespace : "default" ,
967
+ Annotations : map [string ]string {
968
+ "nginx.org/mergeable-ingress-type" : "minion" ,
969
+ },
970
+ },
971
+ ProxySSLName : "coffee-svc.default.svc" ,
972
+ },
973
+ {
974
+ Path : "/tea" ,
975
+ ServiceName : "tea-svc" ,
976
+ Upstream : teaUpstreamNGINXPlus ,
977
+ ProxyConnectTimeout : "60s" ,
978
+ ProxyReadTimeout : "60s" ,
979
+ ProxySendTimeout : "60s" ,
980
+ ClientMaxBodySize : "1m" ,
981
+ ProxyBuffering : true ,
982
+ MinionIngress : & Ingress {
983
+ Name : "cafe-ingress-tea-minion" ,
984
+ Namespace : "default" ,
985
+ Annotations : map [string ]string {
986
+ "nginx.org/mergeable-ingress-type" : "minion" ,
987
+ },
988
+ },
989
+ ProxySSLName : "tea-svc.default.svc" ,
990
+ },
991
+ },
992
+ SSL : true ,
993
+ SSLCertificate : "/etc/nginx/secrets/default-cafe-secret" ,
994
+ SSLCertificateKey : "/etc/nginx/secrets/default-cafe-secret" ,
995
+ StatusZone : "cafe.example.com" ,
996
+ HSTSMaxAge : 2592000 ,
997
+ Ports : []int {80 },
998
+ SSLPorts : []int {443 },
999
+ SSLRedirect : true ,
1000
+ HealthChecks : make (map [string ]HealthCheck ),
1001
+ },
1002
+ },
1003
+ Ingress : Ingress {
1004
+ Name : "cafe-ingress-master" ,
1005
+ Namespace : "default" ,
1006
+ Annotations : map [string ]string {
1007
+ "nginx.org/mergeable-ingress-type" : "master" ,
1008
+ "nginx.org/path-regex" : "case_sensitive" ,
1009
+ },
1010
+ },
1011
+ }
1012
+
918
1013
// ingressCfgMasterMinionNGINXPlusMinionWithPathRegexAnnotation holds data to test the following scenario:
919
1014
//
920
1015
// Ingress Master - Minion
0 commit comments