Skip to content

Commit 8cd4800

Browse files
committed
address comment: use builders for httproute fields
1 parent c46ee64 commit 8cd4800

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

internal/controllers/gateway/route_utils.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ const (
8484
// https://github.com/kubernetes-sigs/gateway-api/pull/1516
8585
// TODO: swap this out with upstream const when released.
8686
RouteReasonNoMatchingParent gatewayv1beta1.RouteConditionReason = "NoMatchingParent"
87-
// This reason is used with the "Accepted" condition when the Gateway has no
88-
// compatible Listeners whose Port matches the route
89-
// NOTE: This should probably be proposed upstream.
90-
RouteReasonNoMatchingListenerPort gatewayv1beta1.RouteConditionReason = "NoMatchingListenerPort"
9187
// This reason is used with the "Accepted" condition when no hostnames in listeners
9288
// could match hostname in the spec of route.
9389
RouteReasonNoMatchingListenerHostname gatewayv1beta1.RouteConditionReason = "NoMatchingListenerHostname"
@@ -520,7 +516,7 @@ func getUnionOfGatewayHostnames(gateways []supportedGatewayWithCondition) ([]gat
520516
if listener.Hostname == nil {
521517
return nil, true
522518
}
523-
hostnames = append(hostnames, (*listener.Hostname))
519+
hostnames = append(hostnames, *listener.Hostname)
524520
}
525521
} else {
526522
for _, listener := range gateway.gateway.Spec.Listeners {
@@ -529,7 +525,7 @@ func getUnionOfGatewayHostnames(gateways []supportedGatewayWithCondition) ([]gat
529525
if listener.Hostname == nil {
530526
return nil, true
531527
}
532-
hostnames = append(hostnames, (*listener.Hostname))
528+
hostnames = append(hostnames, *listener.Hostname)
533529
}
534530
}
535531
}

test/integration/httproute_test.go

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/kong/kubernetes-ingress-controller/v2/internal/annotations"
2424
gatewaypkg "github.com/kong/kubernetes-ingress-controller/v2/internal/controllers/gateway"
2525
"github.com/kong/kubernetes-ingress-controller/v2/internal/util"
26+
"github.com/kong/kubernetes-ingress-controller/v2/internal/util/builder"
2627
"github.com/kong/kubernetes-ingress-controller/v2/internal/versions"
2728
kongv1 "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1"
2829
"github.com/kong/kubernetes-ingress-controller/v2/pkg/clientset"
@@ -541,8 +542,6 @@ func TestHTTPRouteFilterHosts(t *testing.T) {
541542
require.NoError(t, err)
542543

543544
t.Logf("creating an httproute with a same hostname and another unmatched hostname")
544-
httpPort := gatewayv1beta1.PortNumber(80)
545-
pathMatchPrefix := gatewayv1beta1.PathMatchPathPrefix
546545
httpRoute := &gatewayv1beta1.HTTPRoute{
547546
ObjectMeta: metav1.ObjectMeta{
548547
Name: uuid.NewString(),
@@ -563,22 +562,11 @@ func TestHTTPRouteFilterHosts(t *testing.T) {
563562
},
564563
Rules: []gatewayv1beta1.HTTPRouteRule{{
565564
Matches: []gatewayv1beta1.HTTPRouteMatch{
566-
{
567-
Path: &gatewayv1beta1.HTTPPathMatch{
568-
Type: &pathMatchPrefix,
569-
Value: kong.String("/test-http-route-filter-hosts"),
570-
},
571-
},
565+
builder.NewHTTPRouteMatch().WithPathPrefix("/test-http-route-filter-hosts").Build(),
566+
},
567+
BackendRefs: []gatewayv1beta1.HTTPBackendRef{
568+
builder.NewHTTPBackendRef(service.Name).WithPort(80).Build(),
572569
},
573-
BackendRefs: []gatewayv1beta1.HTTPBackendRef{{
574-
BackendRef: gatewayv1beta1.BackendRef{
575-
BackendObjectReference: gatewayv1beta1.BackendObjectReference{
576-
Name: gatewayv1beta1.ObjectName(service.Name),
577-
Port: &httpPort,
578-
Kind: util.StringToGatewayAPIKindPtr("Service"),
579-
},
580-
},
581-
}},
582570
}},
583571
},
584572
}

0 commit comments

Comments
 (0)