@@ -110,16 +110,7 @@ func getIngressRulesFromHTTPRoutesCommonTestCases() []testCaseIngressRulesFromHT
110110 kong .String ("www.konghq.com" ),
111111 },
112112 },
113- Ingress : util.K8sObjectInfo {
114- Name : "basic-httproute" ,
115- Namespace : corev1 .NamespaceDefault ,
116- Annotations : make (map [string ]string ),
117- GroupVersionKind : schema.GroupVersionKind {
118- Group : "gateway.networking.k8s.io" ,
119- Version : "v1beta1" ,
120- Kind : "HTTPRoute" ,
121- },
122- },
113+ Ingress : k8sObjectInfoOfHTTPRoute (routes [0 ]),
123114 }},
124115 Parent : routes [0 ],
125116 },
@@ -216,16 +207,7 @@ func getIngressRulesFromHTTPRoutesCommonTestCases() []testCaseIngressRulesFromHT
216207 },
217208 StripPath : pointer .BoolPtr (false ),
218209 },
219- Ingress : util.K8sObjectInfo {
220- Name : "basic-httproute" ,
221- Namespace : corev1 .NamespaceDefault ,
222- Annotations : make (map [string ]string ),
223- GroupVersionKind : schema.GroupVersionKind {
224- Group : "gateway.networking.k8s.io" ,
225- Version : "v1beta1" ,
226- Kind : "HTTPRoute" ,
227- },
228- },
210+ Ingress : k8sObjectInfoOfHTTPRoute (routes [0 ]),
229211 }},
230212 Parent : routes [0 ],
231213 },
@@ -352,16 +334,7 @@ func getIngressRulesFromHTTPRoutesCommonTestCases() []testCaseIngressRulesFromHT
352334 },
353335 StripPath : pointer .BoolPtr (false ),
354336 },
355- Ingress : util.K8sObjectInfo {
356- Name : "basic-httproute" ,
357- Namespace : corev1 .NamespaceDefault ,
358- Annotations : make (map [string ]string ),
359- GroupVersionKind : schema.GroupVersionKind {
360- Group : "gateway.networking.k8s.io" ,
361- Version : "v1beta1" ,
362- Kind : "HTTPRoute" ,
363- },
364- },
337+ Ingress : k8sObjectInfoOfHTTPRoute (routes [0 ]),
365338 }},
366339 Parent : routes [0 ],
367340 },
@@ -426,16 +399,7 @@ func getIngressRulesFromHTTPRoutesCommonTestCases() []testCaseIngressRulesFromHT
426399 },
427400 StripPath : pointer .BoolPtr (false ),
428401 },
429- Ingress : util.K8sObjectInfo {
430- Name : "basic-httproute" ,
431- Namespace : corev1 .NamespaceDefault ,
432- Annotations : make (map [string ]string ),
433- GroupVersionKind : schema.GroupVersionKind {
434- Group : "gateway.networking.k8s.io" ,
435- Version : "v1beta1" ,
436- Kind : "HTTPRoute" ,
437- },
438- },
402+ Ingress : k8sObjectInfoOfHTTPRoute (routes [0 ]),
439403 }},
440404 Parent : routes [0 ],
441405 },
@@ -520,16 +484,7 @@ func getIngressRulesFromHTTPRoutesCombinedRoutesTestCases() []testCaseIngressRul
520484 },
521485 StripPath : pointer .BoolPtr (false ),
522486 },
523- Ingress : util.K8sObjectInfo {
524- Name : "basic-httproute" ,
525- Namespace : corev1 .NamespaceDefault ,
526- Annotations : make (map [string ]string ),
527- GroupVersionKind : schema.GroupVersionKind {
528- Group : "gateway.networking.k8s.io" ,
529- Version : "v1beta1" ,
530- Kind : "HTTPRoute" ,
531- },
532- },
487+ Ingress : k8sObjectInfoOfHTTPRoute (routes [0 ]),
533488 },
534489 {
535490 Route : kong.Route {
@@ -544,16 +499,7 @@ func getIngressRulesFromHTTPRoutesCombinedRoutesTestCases() []testCaseIngressRul
544499 },
545500 StripPath : pointer .BoolPtr (false ),
546501 },
547- Ingress : util.K8sObjectInfo {
548- Name : "basic-httproute" ,
549- Namespace : corev1 .NamespaceDefault ,
550- Annotations : make (map [string ]string ),
551- GroupVersionKind : schema.GroupVersionKind {
552- Group : "gateway.networking.k8s.io" ,
553- Version : "v1beta1" ,
554- Kind : "HTTPRoute" ,
555- },
556- },
502+ Ingress : k8sObjectInfoOfHTTPRoute (routes [0 ]),
557503 },
558504 },
559505 Parent : routes [0 ],
@@ -641,16 +587,7 @@ func getIngressRulesFromHTTPRoutesCombinedRoutesTestCases() []testCaseIngressRul
641587 },
642588 StripPath : pointer .BoolPtr (false ),
643589 },
644- Ingress : util.K8sObjectInfo {
645- Name : "basic-httproute" ,
646- Namespace : corev1 .NamespaceDefault ,
647- Annotations : make (map [string ]string ),
648- GroupVersionKind : schema.GroupVersionKind {
649- Group : "gateway.networking.k8s.io" ,
650- Version : "v1beta1" ,
651- Kind : "HTTPRoute" ,
652- },
653- },
590+ Ingress : k8sObjectInfoOfHTTPRoute (routes [0 ]),
654591 }},
655592 Parent : & gatewayv1beta1.HTTPRoute {
656593 Spec : gatewayv1beta1.HTTPRouteSpec {
@@ -744,16 +681,7 @@ func getIngressRulesFromHTTPRoutesCombinedRoutesTestCases() []testCaseIngressRul
744681 },
745682 StripPath : pointer .BoolPtr (false ),
746683 },
747- Ingress : util.K8sObjectInfo {
748- Name : "basic-httproute" ,
749- Namespace : corev1 .NamespaceDefault ,
750- Annotations : make (map [string ]string ),
751- GroupVersionKind : schema.GroupVersionKind {
752- Group : "gateway.networking.k8s.io" ,
753- Version : "v1beta1" ,
754- Kind : "HTTPRoute" ,
755- },
756- },
684+ Ingress : k8sObjectInfoOfHTTPRoute (routes [0 ]),
757685 }},
758686 Parent : routes [0 ],
759687 },
@@ -856,16 +784,7 @@ func getIngressRulesFromHTTPRoutesCombinedRoutesTestCases() []testCaseIngressRul
856784 },
857785 StripPath : pointer .BoolPtr (false ),
858786 },
859- Ingress : util.K8sObjectInfo {
860- Name : "basic-httproute" ,
861- Namespace : corev1 .NamespaceDefault ,
862- Annotations : make (map [string ]string ),
863- GroupVersionKind : schema.GroupVersionKind {
864- Group : "gateway.networking.k8s.io" ,
865- Version : "v1beta1" ,
866- Kind : "HTTPRoute" ,
867- },
868- },
787+ Ingress : k8sObjectInfoOfHTTPRoute (routes [0 ]),
869788 },
870789 {
871790 Route : kong.Route {
@@ -880,16 +799,7 @@ func getIngressRulesFromHTTPRoutesCombinedRoutesTestCases() []testCaseIngressRul
880799 },
881800 StripPath : pointer .BoolPtr (false ),
882801 },
883- Ingress : util.K8sObjectInfo {
884- Name : "basic-httproute" ,
885- Namespace : corev1 .NamespaceDefault ,
886- Annotations : make (map [string ]string ),
887- GroupVersionKind : schema.GroupVersionKind {
888- Group : "gateway.networking.k8s.io" ,
889- Version : "v1beta1" ,
890- Kind : "HTTPRoute" ,
891- },
892- },
802+ Ingress : k8sObjectInfoOfHTTPRoute (routes [0 ]),
893803 },
894804 },
895805 Parent : & gatewayv1beta1.HTTPRoute {
@@ -1038,16 +948,7 @@ func getIngressRulesFromHTTPRoutesCombinedRoutesTestCases() []testCaseIngressRul
1038948 },
1039949 StripPath : pointer .BoolPtr (false ),
1040950 },
1041- Ingress : util.K8sObjectInfo {
1042- Name : "basic-httproute" ,
1043- Namespace : corev1 .NamespaceDefault ,
1044- Annotations : make (map [string ]string ),
1045- GroupVersionKind : schema.GroupVersionKind {
1046- Group : "gateway.networking.k8s.io" ,
1047- Version : "v1beta1" ,
1048- Kind : "HTTPRoute" ,
1049- },
1050- },
951+ Ingress : k8sObjectInfoOfHTTPRoute (routes [0 ]),
1051952 },
1052953 },
1053954 Parent : routes [0 ],
@@ -1254,16 +1155,7 @@ func TestIngressRulesFromHTTPRoutes_RegexPrefix(t *testing.T) {
12541155 },
12551156 StripPath : pointer .BoolPtr (false ),
12561157 },
1257- Ingress : util.K8sObjectInfo {
1258- Name : "basic-httproute" ,
1259- Namespace : corev1 .NamespaceDefault ,
1260- Annotations : make (map [string ]string ),
1261- GroupVersionKind : schema.GroupVersionKind {
1262- Group : "gateway.networking.k8s.io" ,
1263- Version : "v1beta1" ,
1264- Kind : "HTTPRoute" ,
1265- },
1266- },
1158+ Ingress : k8sObjectInfoOfHTTPRoute (routes [0 ]),
12671159 }},
12681160 Parent : routes [0 ],
12691161 },
@@ -1305,3 +1197,22 @@ func TestIngressRulesFromHTTPRoutes_RegexPrefix(t *testing.T) {
13051197func HTTPMethodPointer (method string ) * gatewayv1beta1.HTTPMethod {
13061198 return (* gatewayv1beta1 .HTTPMethod )(& method )
13071199}
1200+
1201+ func k8sObjectInfoOfHTTPRoute (route * gatewayv1beta1.HTTPRoute ) util.K8sObjectInfo {
1202+ // parsers always provide the annotations map, even if route didn't have any
1203+ anotations := route .Annotations
1204+ if anotations == nil {
1205+ anotations = make (map [string ]string )
1206+ }
1207+
1208+ return util.K8sObjectInfo {
1209+ Name : route .Name ,
1210+ Namespace : route .Namespace ,
1211+ Annotations : anotations ,
1212+ GroupVersionKind : schema.GroupVersionKind {
1213+ Group : "gateway.networking.k8s.io" ,
1214+ Version : "v1beta1" ,
1215+ Kind : "HTTPRoute" ,
1216+ },
1217+ }
1218+ }
0 commit comments