@@ -96,14 +96,8 @@ func (gwr *GatewayAPIRouter) Reconcile(canary *flaggerv1.Canary) error {
96
96
Matches : matches ,
97
97
Filters : gwr .makeFilters (canary ),
98
98
BackendRefs : []v1.HTTPBackendRef {
99
- {
100
- BackendRef : gwr .makeBackendRef (primarySvcName , initialPrimaryWeight , canary .Spec .Service .Port , & canary .Spec .Service .Primary .BackendRef .BackendRef ),
101
- Filters : canary .Spec .Service .Primary .BackendRef .Filters ,
102
- },
103
- {
104
- BackendRef : gwr .makeBackendRef (canarySvcName , initialCanaryWeight , canary .Spec .Service .Port , & canary .Spec .Service .Canary .BackendRef .BackendRef ),
105
- Filters : canary .Spec .Service .Canary .BackendRef .Filters ,
106
- },
99
+ gwr .makeHTTPBackendRef (primarySvcName , initialPrimaryWeight , canary .Spec .Service .Port , canary .Spec .Service .Primary ),
100
+ gwr .makeHTTPBackendRef (canarySvcName , initialCanaryWeight , canary .Spec .Service .Port , canary .Spec .Service .Canary ),
107
101
},
108
102
},
109
103
},
@@ -124,10 +118,7 @@ func (gwr *GatewayAPIRouter) Reconcile(canary *flaggerv1.Canary) error {
124
118
Matches : matches ,
125
119
Filters : gwr .makeFilters (canary ),
126
120
BackendRefs : []v1.HTTPBackendRef {
127
- {
128
- BackendRef : gwr .makeBackendRef (primarySvcName , initialPrimaryWeight , canary .Spec .Service .Port , & canary .Spec .Service .Primary .BackendRef .BackendRef ),
129
- Filters : canary .Spec .Service .Primary .BackendRef .Filters ,
130
- },
121
+ gwr .makeHTTPBackendRef (primarySvcName , initialPrimaryWeight , canary .Spec .Service .Port , canary .Spec .Service .Primary ),
131
122
},
132
123
})
133
124
if canary .Spec .Service .Timeout != "" {
@@ -394,14 +385,8 @@ func (gwr *GatewayAPIRouter) SetRoutes(
394
385
Matches : matches ,
395
386
Filters : gwr .makeFilters (canary ),
396
387
BackendRefs : []v1.HTTPBackendRef {
397
- {
398
- BackendRef : gwr .makeBackendRef (primarySvcName , pWeight , canary .Spec .Service .Port , & canary .Spec .Service .Primary .BackendRef .BackendRef ),
399
- Filters : canary .Spec .Service .Primary .BackendRef .Filters ,
400
- },
401
- {
402
- BackendRef : gwr .makeBackendRef (canarySvcName , cWeight , canary .Spec .Service .Port , & canary .Spec .Service .Canary .BackendRef .BackendRef ),
403
- Filters : canary .Spec .Service .Canary .BackendRef .Filters ,
404
- },
388
+ gwr .makeHTTPBackendRef (primarySvcName , pWeight , canary .Spec .Service .Port , canary .Spec .Service .Primary ),
389
+ gwr .makeHTTPBackendRef (canarySvcName , cWeight , canary .Spec .Service .Port , canary .Spec .Service .Canary ),
405
390
},
406
391
}
407
392
if canary .Spec .Service .Timeout != "" {
@@ -455,10 +440,7 @@ func (gwr *GatewayAPIRouter) SetRoutes(
455
440
Matches : matches ,
456
441
Filters : gwr .makeFilters (canary ),
457
442
BackendRefs : []v1.HTTPBackendRef {
458
- {
459
- BackendRef : gwr .makeBackendRef (primarySvcName , initialPrimaryWeight , canary .Spec .Service .Port , & canary .Spec .Service .Primary .BackendRef .BackendRef ),
460
- Filters : canary .Spec .Service .Primary .BackendRef .Filters ,
461
- },
443
+ gwr .makeHTTPBackendRef (primarySvcName , initialPrimaryWeight , canary .Spec .Service .Port , canary .Spec .Service .Primary ),
462
444
},
463
445
Timeouts : & v1.HTTPRouteTimeouts {
464
446
Request : & timeout ,
@@ -541,14 +523,8 @@ func (gwr *GatewayAPIRouter) getSessionAffinityRouteRules(canary *flaggerv1.Cana
541
523
mergedMatches := gwr .mergeMatchConditions ([]v1.HTTPRouteMatch {cookieMatch }, svcMatches )
542
524
stickyRouteRule .Matches = mergedMatches
543
525
stickyRouteRule .BackendRefs = []v1.HTTPBackendRef {
544
- {
545
- BackendRef : gwr .makeBackendRef (primarySvcName , 0 , canary .Spec .Service .Port , & canary .Spec .Service .Primary .BackendRef .BackendRef ),
546
- Filters : canary .Spec .Service .Primary .BackendRef .Filters ,
547
- },
548
- {
549
- BackendRef : gwr .makeBackendRef (canarySvcName , 100 , canary .Spec .Service .Port , & canary .Spec .Service .Canary .BackendRef .BackendRef ),
550
- Filters : canary .Spec .Service .Canary .BackendRef .Filters ,
551
- },
526
+ gwr .makeHTTPBackendRef (primarySvcName , 0 , canary .Spec .Service .Port , canary .Spec .Service .Primary ),
527
+ gwr .makeHTTPBackendRef (canarySvcName , 100 , canary .Spec .Service .Port , canary .Spec .Service .Canary ),
552
528
}
553
529
} else {
554
530
// If canary weight is 0 and SessionAffinityCookie is non-blank, then it belongs to a previous canary run.
@@ -671,21 +647,28 @@ func (gwr *GatewayAPIRouter) mapRouteMatches(requestMatches []istiov1beta1.HTTPM
671
647
return matches , nil
672
648
}
673
649
674
- func (gwr * GatewayAPIRouter ) makeBackendRef (svcName string , weight , port int32 , backendRefTemplate * v1.BackendRef ) v1.BackendRef {
675
- if backendRefTemplate != nil {
676
- backendRefTemplate .Weight = & weight
677
- return * backendRefTemplate
678
- }
679
-
680
- return v1.BackendRef {
681
- BackendObjectReference : v1.BackendObjectReference {
682
- Group : (* v1 .Group )(& backendRefGroup ),
683
- Kind : (* v1 .Kind )(& backendRefKind ),
684
- Name : v1 .ObjectName (svcName ),
685
- Port : (* v1 .PortNumber )(& port ),
650
+ func (gwr * GatewayAPIRouter ) makeHTTPBackendRef (svcName string , weight , port int32 , customBackend * flaggerv1.CustomBackend ) v1.HTTPBackendRef {
651
+ httpBackendRef := v1.HTTPBackendRef {
652
+ BackendRef : v1.BackendRef {
653
+ BackendObjectReference : v1.BackendObjectReference {
654
+ Group : (* v1 .Group )(& backendRefGroup ),
655
+ Kind : (* v1 .Kind )(& backendRefKind ),
656
+ Name : v1 .ObjectName (svcName ),
657
+ Port : (* v1 .PortNumber )(& port ),
658
+ },
659
+ Weight : & weight ,
686
660
},
687
- Weight : & weight ,
688
661
}
662
+ if customBackend != nil && customBackend .Backend != nil {
663
+ if customBackend .Backend .BackendObjectReference != nil {
664
+ httpBackendRef .BackendObjectReference = * customBackend .Backend .BackendObjectReference
665
+ }
666
+ if customBackend .Backend .Filters != nil {
667
+ httpBackendRef .Filters = customBackend .Backend .Filters
668
+ }
669
+ }
670
+
671
+ return httpBackendRef
689
672
}
690
673
691
674
func (gwr * GatewayAPIRouter ) mergeMatchConditions (analysis , service []v1.HTTPRouteMatch ) []v1.HTTPRouteMatch {
0 commit comments