Skip to content

Commit d8712c3

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

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

internal/controllers/gateway/route_utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ func getUnionOfGatewayHostnames(gateways []supportedGatewayWithCondition) ([]gat
520520
if listener.Hostname == nil {
521521
return nil, true
522522
}
523-
hostnames = append(hostnames, (*listener.Hostname))
523+
hostnames = append(hostnames, *listener.Hostname)
524524
}
525525
} else {
526526
for _, listener := range gateway.gateway.Spec.Listeners {
@@ -529,7 +529,7 @@ func getUnionOfGatewayHostnames(gateways []supportedGatewayWithCondition) ([]gat
529529
if listener.Hostname == nil {
530530
return nil, true
531531
}
532-
hostnames = append(hostnames, (*listener.Hostname))
532+
hostnames = append(hostnames, *listener.Hostname)
533533
}
534534
}
535535
}

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)