@@ -170,6 +170,18 @@ func createBackendRef(
170
170
}
171
171
}
172
172
173
+ func createRouteBackendRefs (refs []v1.HTTPBackendRef ) []graph.RouteBackendRef {
174
+ rbrs := make ([]graph.RouteBackendRef , 0 , len (refs ))
175
+ for _ , ref := range refs {
176
+ rbr := graph.RouteBackendRef {
177
+ BackendRef : ref .BackendRef ,
178
+ Filters : []any {},
179
+ }
180
+ rbrs = append (rbrs , rbr )
181
+ }
182
+ return rbrs
183
+ }
184
+
173
185
func createAlwaysValidValidators () validation.Validators {
174
186
http := & validationfakes.FakeHTTPFieldsValidator {}
175
187
@@ -286,9 +298,10 @@ var _ = Describe("ChangeProcessor", func() {
286
298
gw1 , gw1Updated , gw2 * v1.Gateway
287
299
refGrant1 , refGrant2 * v1beta1.ReferenceGrant
288
300
expGraph * graph.Graph
289
- expRouteHR1 , expRouteHR2 * graph.HTTPRoute
301
+ expRouteHR1 , expRouteHR2 * graph.L7Route
290
302
hr1Name , hr2Name types.NamespacedName
291
303
gatewayAPICRD , gatewayAPICRDUpdated * metav1.PartialObjectMetadata
304
+ routeKey1 , routeKey2 graph.RouteKey
292
305
)
293
306
BeforeAll (func () {
294
307
gcUpdated = gc .DeepCopy ()
@@ -308,12 +321,22 @@ var _ = Describe("ChangeProcessor", func() {
308
321
hr1 = createRoute ("hr-1" , "gateway-1" , "foo.example.com" , crossNsBackendRef )
309
322
hr1Name = types.NamespacedName {Namespace : hr1 .Namespace , Name : hr1 .Name }
310
323
324
+ routeKey1 = graph.RouteKey {
325
+ NamespacedName : hr1Name ,
326
+ RouteType : graph .RouteTypeHTTP ,
327
+ }
328
+
311
329
hr1Updated = hr1 .DeepCopy ()
312
330
hr1Updated .Generation ++
313
331
314
332
hr2 = createRoute ("hr-2" , "gateway-2" , "bar.example.com" )
315
333
hr2Name = types.NamespacedName {Namespace : "test" , Name : "hr-2" }
316
334
335
+ routeKey2 = graph.RouteKey {
336
+ NamespacedName : hr2Name ,
337
+ RouteType : graph .RouteTypeHTTP ,
338
+ }
339
+
317
340
refGrant1 = & v1beta1.ReferenceGrant {
318
341
ObjectMeta : metav1.ObjectMeta {
319
342
Namespace : "cert-ns" ,
@@ -404,8 +427,10 @@ var _ = Describe("ChangeProcessor", func() {
404
427
gatewayAPICRDUpdated .Annotations [gatewayclass .BundleVersionAnnotation ] = "v1.99.0"
405
428
})
406
429
BeforeEach (func () {
407
- expRouteHR1 = & graph.HTTPRoute {
408
- Source : hr1 ,
430
+ expRouteHR1 = & graph.L7Route {
431
+ Source : hr1 ,
432
+ RouteType : graph .RouteTypeHTTP ,
433
+ SrcParentRefs : hr1 .Spec .ParentRefs ,
409
434
ParentRefs : []graph.ParentRef {
410
435
{
411
436
Attachment : & graph.ParentRefAttachmentStatus {
@@ -423,16 +448,21 @@ var _ = Describe("ChangeProcessor", func() {
423
448
Idx : 1 ,
424
449
},
425
450
},
426
- Rules : []graph.Rule {
427
- {
428
- BackendRefs : []graph.BackendRef {
429
- {
430
- SvcNsName : types.NamespacedName {Namespace : "service-ns" , Name : "service" },
431
- Weight : 1 ,
451
+ Spec : graph.L7RouteSpec {
452
+ Hostnames : hr1 .Spec .Hostnames ,
453
+ Rules : []graph.RouteRule {
454
+ {
455
+ BackendRefs : []graph.BackendRef {
456
+ {
457
+ SvcNsName : types.NamespacedName {Namespace : "service-ns" , Name : "service" },
458
+ Weight : 1 ,
459
+ },
432
460
},
461
+ ValidMatches : true ,
462
+ ValidFilters : true ,
463
+ Matches : hr1 .Spec .Rules [0 ].Matches ,
464
+ RouteBackendRefs : createRouteBackendRefs (hr1 .Spec .Rules [0 ].BackendRefs ),
433
465
},
434
- ValidMatches : true ,
435
- ValidFilters : true ,
436
466
},
437
467
},
438
468
Valid : true ,
@@ -444,8 +474,10 @@ var _ = Describe("ChangeProcessor", func() {
444
474
},
445
475
}
446
476
447
- expRouteHR2 = & graph.HTTPRoute {
448
- Source : hr2 ,
477
+ expRouteHR2 = & graph.L7Route {
478
+ Source : hr2 ,
479
+ RouteType : graph .RouteTypeHTTP ,
480
+ SrcParentRefs : hr2 .Spec .ParentRefs ,
449
481
ParentRefs : []graph.ParentRef {
450
482
{
451
483
Attachment : & graph.ParentRefAttachmentStatus {
@@ -463,7 +495,17 @@ var _ = Describe("ChangeProcessor", func() {
463
495
Idx : 1 ,
464
496
},
465
497
},
466
- Rules : []graph.Rule {{ValidMatches : true , ValidFilters : true }},
498
+ Spec : graph.L7RouteSpec {
499
+ Hostnames : hr2 .Spec .Hostnames ,
500
+ Rules : []graph.RouteRule {
501
+ {
502
+ ValidMatches : true ,
503
+ ValidFilters : true ,
504
+ Matches : hr2 .Spec .Rules [0 ].Matches ,
505
+ RouteBackendRefs : []graph.RouteBackendRef {},
506
+ },
507
+ },
508
+ },
467
509
Valid : true ,
468
510
Attachable : true ,
469
511
}
@@ -479,36 +521,27 @@ var _ = Describe("ChangeProcessor", func() {
479
521
Source : gw1 ,
480
522
Listeners : []* graph.Listener {
481
523
{
482
- Name : "listener-80-1" ,
483
- Source : gw1 .Spec .Listeners [0 ],
484
- Valid : true ,
485
- Attachable : true ,
486
- GRPCRoutes : map [types.NamespacedName ]* graph.GRPCRoute {},
487
- HTTPRoutes : map [types.NamespacedName ]* graph.HTTPRoute {
488
- {Namespace : "test" , Name : "hr-1" }: expRouteHR1 ,
489
- },
524
+ Name : "listener-80-1" ,
525
+ Source : gw1 .Spec .Listeners [0 ],
526
+ Valid : true ,
527
+ Attachable : true ,
528
+ Routes : map [graph.RouteKey ]* graph.L7Route {routeKey1 : expRouteHR1 },
490
529
SupportedKinds : []v1.RouteGroupKind {{Kind : "HTTPRoute" }},
491
530
},
492
531
{
493
- Name : "listener-443-1" ,
494
- Source : gw1 .Spec .Listeners [1 ],
495
- Valid : true ,
496
- Attachable : true ,
497
- GRPCRoutes : map [types.NamespacedName ]* graph.GRPCRoute {},
498
- HTTPRoutes : map [types.NamespacedName ]* graph.HTTPRoute {
499
- {Namespace : "test" , Name : "hr-1" }: expRouteHR1 ,
500
- },
532
+ Name : "listener-443-1" ,
533
+ Source : gw1 .Spec .Listeners [1 ],
534
+ Valid : true ,
535
+ Attachable : true ,
536
+ Routes : map [graph.RouteKey ]* graph.L7Route {routeKey1 : expRouteHR1 },
501
537
ResolvedSecret : helpers .GetPointer (client .ObjectKeyFromObject (diffNsTLSSecret )),
502
538
SupportedKinds : []v1.RouteGroupKind {{Kind : "HTTPRoute" }},
503
539
},
504
540
},
505
541
Valid : true ,
506
542
},
507
- IgnoredGateways : map [types.NamespacedName ]* v1.Gateway {},
508
- GRPCRoutes : map [types.NamespacedName ]* graph.GRPCRoute {},
509
- HTTPRoutes : map [types.NamespacedName ]* graph.HTTPRoute {
510
- {Namespace : "test" , Name : "hr-1" }: expRouteHR1 ,
511
- },
543
+ IgnoredGateways : map [types.NamespacedName ]* v1.Gateway {},
544
+ Routes : map [graph.RouteKey ]* graph.L7Route {routeKey1 : expRouteHR1 },
512
545
ReferencedSecrets : map [types.NamespacedName ]* graph.Secret {},
513
546
ReferencedServices : map [types.NamespacedName ]struct {}{
514
547
{
@@ -569,24 +602,24 @@ var _ = Describe("ChangeProcessor", func() {
569
602
expGraph .Gateway .Listeners = nil
570
603
571
604
// no ref grant exists yet for hr1
572
- expGraph .HTTPRoutes [ hr1Name ].Conditions = []conditions.Condition {
605
+ expGraph .Routes [ routeKey1 ].Conditions = []conditions.Condition {
573
606
staticConds .NewRouteBackendRefRefNotPermitted (
574
607
"Backend ref to Service service-ns/service not permitted by any ReferenceGrant" ,
575
608
),
576
609
}
577
- expGraph .HTTPRoutes [ hr1Name ].ParentRefs [0 ].Attachment = & graph.ParentRefAttachmentStatus {
610
+ expGraph .Routes [ routeKey1 ].ParentRefs [0 ].Attachment = & graph.ParentRefAttachmentStatus {
578
611
AcceptedHostnames : map [string ][]string {},
579
612
FailedCondition : staticConds .NewRouteNoMatchingParent (),
580
613
}
581
- expGraph .HTTPRoutes [ hr1Name ].ParentRefs [1 ].Attachment = & graph.ParentRefAttachmentStatus {
614
+ expGraph .Routes [ routeKey1 ].ParentRefs [1 ].Attachment = & graph.ParentRefAttachmentStatus {
582
615
AcceptedHostnames : map [string ][]string {},
583
616
FailedCondition : staticConds .NewRouteNoMatchingParent (),
584
617
}
585
618
586
619
expGraph .ReferencedSecrets = nil
587
620
expGraph .ReferencedServices = nil
588
621
589
- expRouteHR1 .Rules [0 ].BackendRefs [0 ].SvcNsName = types.NamespacedName {}
622
+ expRouteHR1 .Spec . Rules [0 ].BackendRefs [0 ].SvcNsName = types.NamespacedName {}
590
623
591
624
changed , graphCfg := processor .Process ()
592
625
Expect (changed ).To (Equal (state .ClusterStateChange ))
@@ -624,23 +657,23 @@ var _ = Describe("ChangeProcessor", func() {
624
657
}
625
658
626
659
listener80 := getListenerByName (expGraph .Gateway , "listener-80-1" )
627
- listener80 .HTTPRoutes [ hr1Name ].ParentRefs [0 ].Attachment = expAttachment80
628
- listener443 .HTTPRoutes [ hr1Name ].ParentRefs [1 ].Attachment = expAttachment443
660
+ listener80 .Routes [ routeKey1 ].ParentRefs [0 ].Attachment = expAttachment80
661
+ listener443 .Routes [ routeKey1 ].ParentRefs [1 ].Attachment = expAttachment443
629
662
630
663
// no ref grant exists yet for hr1
631
- expGraph .HTTPRoutes [ hr1Name ].Conditions = []conditions.Condition {
664
+ expGraph .Routes [ routeKey1 ].Conditions = []conditions.Condition {
632
665
staticConds .NewRouteInvalidListener (),
633
666
staticConds .NewRouteBackendRefRefNotPermitted (
634
667
"Backend ref to Service service-ns/service not permitted by any ReferenceGrant" ,
635
668
),
636
669
}
637
- expGraph .HTTPRoutes [ hr1Name ].ParentRefs [0 ].Attachment = expAttachment80
638
- expGraph .HTTPRoutes [ hr1Name ].ParentRefs [1 ].Attachment = expAttachment443
670
+ expGraph .Routes [ routeKey1 ].ParentRefs [0 ].Attachment = expAttachment80
671
+ expGraph .Routes [ routeKey1 ].ParentRefs [1 ].Attachment = expAttachment443
639
672
640
673
expGraph .ReferencedSecrets = nil
641
674
expGraph .ReferencedServices = nil
642
675
643
- expRouteHR1 .Rules [0 ].BackendRefs [0 ].SvcNsName = types.NamespacedName {}
676
+ expRouteHR1 .Spec . Rules [0 ].BackendRefs [0 ].SvcNsName = types.NamespacedName {}
644
677
645
678
changed , graphCfg := processor .Process ()
646
679
Expect (changed ).To (Equal (state .ClusterStateChange ))
@@ -653,7 +686,7 @@ var _ = Describe("ChangeProcessor", func() {
653
686
processor .CaptureUpsertChange (refGrant1 )
654
687
655
688
// no ref grant exists yet for hr1
656
- expGraph .HTTPRoutes [ hr1Name ].Conditions = []conditions.Condition {
689
+ expGraph .Routes [ routeKey1 ].Conditions = []conditions.Condition {
657
690
staticConds .NewRouteBackendRefRefNotPermitted (
658
691
"Backend ref to Service service-ns/service not permitted by any ReferenceGrant" ,
659
692
),
@@ -663,7 +696,7 @@ var _ = Describe("ChangeProcessor", func() {
663
696
}
664
697
665
698
expGraph .ReferencedServices = nil
666
- expRouteHR1 .Rules [0 ].BackendRefs [0 ].SvcNsName = types.NamespacedName {}
699
+ expRouteHR1 .Spec . Rules [0 ].BackendRefs [0 ].SvcNsName = types.NamespacedName {}
667
700
668
701
changed , graphCfg := processor .Process ()
669
702
Expect (changed ).To (Equal (state .ClusterStateChange ))
@@ -743,10 +776,10 @@ var _ = Describe("ChangeProcessor", func() {
743
776
processor .CaptureUpsertChange (hr1Updated )
744
777
745
778
listener443 := getListenerByName (expGraph .Gateway , "listener-443-1" )
746
- listener443 .HTTPRoutes [ hr1Name ].Source .Generation = hr1Updated .Generation
779
+ listener443 .Routes [ routeKey1 ].Source .SetGeneration ( hr1Updated .Generation )
747
780
748
781
listener80 := getListenerByName (expGraph .Gateway , "listener-80-1" )
749
- listener80 .HTTPRoutes [ hr1Name ].Source .Generation = hr1Updated .Generation
782
+ listener80 .Routes [ routeKey1 ].Source .SetGeneration ( hr1Updated .Generation )
750
783
expGraph .ReferencedSecrets [client .ObjectKeyFromObject (diffNsTLSSecret )] = & graph.Secret {
751
784
Source : diffNsTLSSecret ,
752
785
}
@@ -852,12 +885,12 @@ var _ = Describe("ChangeProcessor", func() {
852
885
expGraph .IgnoredGateways = map [types.NamespacedName ]* v1.Gateway {
853
886
{Namespace : "test" , Name : "gateway-2" }: gw2 ,
854
887
}
855
- expGraph .HTTPRoutes [ hr2Name ] = expRouteHR2
856
- expGraph .HTTPRoutes [ hr2Name ].ParentRefs [0 ].Attachment = & graph.ParentRefAttachmentStatus {
888
+ expGraph .Routes [ routeKey2 ] = expRouteHR2
889
+ expGraph .Routes [ routeKey2 ].ParentRefs [0 ].Attachment = & graph.ParentRefAttachmentStatus {
857
890
AcceptedHostnames : map [string ][]string {},
858
891
FailedCondition : staticConds .NewTODO ("Gateway is ignored" ),
859
892
}
860
- expGraph .HTTPRoutes [ hr2Name ].ParentRefs [1 ].Attachment = & graph.ParentRefAttachmentStatus {
893
+ expGraph .Routes [ routeKey2 ].ParentRefs [1 ].Attachment = & graph.ParentRefAttachmentStatus {
861
894
AcceptedHostnames : map [string ][]string {},
862
895
FailedCondition : staticConds .NewTODO ("Gateway is ignored" ),
863
896
}
@@ -886,19 +919,19 @@ var _ = Describe("ChangeProcessor", func() {
886
919
expGraph .Gateway .Source = gw2
887
920
listener80 .Source = gw2 .Spec .Listeners [0 ]
888
921
listener443 .Source = gw2 .Spec .Listeners [1 ]
889
- delete (listener80 .HTTPRoutes , hr1Name )
890
- delete (listener443 .HTTPRoutes , hr1Name )
891
- listener80 .HTTPRoutes [ hr2Name ] = expRouteHR2
892
- listener443 .HTTPRoutes [ hr2Name ] = expRouteHR2
893
- delete (expGraph .HTTPRoutes , hr1Name )
894
- expGraph .HTTPRoutes [ hr2Name ] = expRouteHR2
922
+ delete (listener80 .Routes , routeKey1 )
923
+ delete (listener443 .Routes , routeKey1 )
924
+ listener80 .Routes [ routeKey2 ] = expRouteHR2
925
+ listener443 .Routes [ routeKey2 ] = expRouteHR2
926
+ delete (expGraph .Routes , routeKey1 )
927
+ expGraph .Routes [ routeKey2 ] = expRouteHR2
895
928
sameNsTLSSecretRef := helpers .GetPointer (client .ObjectKeyFromObject (sameNsTLSSecret ))
896
929
listener443 .ResolvedSecret = sameNsTLSSecretRef
897
930
expGraph .ReferencedSecrets [client .ObjectKeyFromObject (sameNsTLSSecret )] = & graph.Secret {
898
931
Source : sameNsTLSSecret ,
899
932
}
900
933
901
- expRouteHR1 .Rules [0 ].BackendRefs [0 ].SvcNsName = types.NamespacedName {}
934
+ expRouteHR1 .Spec . Rules [0 ].BackendRefs [0 ].SvcNsName = types.NamespacedName {}
902
935
expGraph .ReferencedServices = nil
903
936
904
937
changed , graphCfg := processor .Process ()
@@ -922,16 +955,16 @@ var _ = Describe("ChangeProcessor", func() {
922
955
expGraph .Gateway .Source = gw2
923
956
listener80 .Source = gw2 .Spec .Listeners [0 ]
924
957
listener443 .Source = gw2 .Spec .Listeners [1 ]
925
- delete (listener80 .HTTPRoutes , hr1Name )
926
- delete (listener443 .HTTPRoutes , hr1Name )
927
- expGraph .HTTPRoutes = map [types. NamespacedName ]* graph.HTTPRoute {}
958
+ delete (listener80 .Routes , routeKey1 )
959
+ delete (listener443 .Routes , routeKey1 )
960
+ expGraph .Routes = map [graph. RouteKey ]* graph.L7Route {}
928
961
sameNsTLSSecretRef := helpers .GetPointer (client .ObjectKeyFromObject (sameNsTLSSecret ))
929
962
listener443 .ResolvedSecret = sameNsTLSSecretRef
930
963
expGraph .ReferencedSecrets [client .ObjectKeyFromObject (sameNsTLSSecret )] = & graph.Secret {
931
964
Source : sameNsTLSSecret ,
932
965
}
933
966
934
- expRouteHR1 .Rules [0 ].BackendRefs [0 ].SvcNsName = types.NamespacedName {}
967
+ expRouteHR1 .Spec . Rules [0 ].BackendRefs [0 ].SvcNsName = types.NamespacedName {}
935
968
expGraph .ReferencedServices = nil
936
969
937
970
changed , graphCfg := processor .Process ()
@@ -952,10 +985,10 @@ var _ = Describe("ChangeProcessor", func() {
952
985
Source : gw2 ,
953
986
Conditions : staticConds .NewGatewayInvalid ("GatewayClass doesn't exist" ),
954
987
}
955
- expGraph .HTTPRoutes = map [types. NamespacedName ]* graph.HTTPRoute {}
988
+ expGraph .Routes = map [graph. RouteKey ]* graph.L7Route {}
956
989
expGraph .ReferencedSecrets = nil
957
990
958
- expRouteHR1 .Rules [0 ].BackendRefs [0 ].SvcNsName = types.NamespacedName {}
991
+ expRouteHR1 .Spec . Rules [0 ].BackendRefs [0 ].SvcNsName = types.NamespacedName {}
959
992
expGraph .ReferencedServices = nil
960
993
961
994
changed , graphCfg := processor .Process ()
@@ -971,7 +1004,7 @@ var _ = Describe("ChangeProcessor", func() {
971
1004
types.NamespacedName {Namespace : "test" , Name : "gateway-2" },
972
1005
)
973
1006
974
- expRouteHR1 .Rules [0 ].BackendRefs [0 ].SvcNsName = types.NamespacedName {}
1007
+ expRouteHR1 .Spec . Rules [0 ].BackendRefs [0 ].SvcNsName = types.NamespacedName {}
975
1008
expGraph .ReferencedServices = nil
976
1009
977
1010
changed , graphCfg := processor .Process ()
@@ -987,7 +1020,7 @@ var _ = Describe("ChangeProcessor", func() {
987
1020
types.NamespacedName {Namespace : "test" , Name : "hr-1" },
988
1021
)
989
1022
990
- expRouteHR1 .Rules [0 ].BackendRefs [0 ].SvcNsName = types.NamespacedName {}
1023
+ expRouteHR1 .Spec . Rules [0 ].BackendRefs [0 ].SvcNsName = types.NamespacedName {}
991
1024
expGraph .ReferencedServices = nil
992
1025
993
1026
changed , graphCfg := processor .Process ()
0 commit comments