Skip to content

Commit

Permalink
chore: bump gateway API to 1.0.0-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
randmonkey committed Oct 20, 2023
1 parent 1ceb6a8 commit 755d230
Show file tree
Hide file tree
Showing 29 changed files with 295 additions and 294 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ require (
k8s.io/client-go v0.28.2
k8s.io/component-base v0.28.2
sigs.k8s.io/controller-runtime v0.16.2
sigs.k8s.io/gateway-api v0.8.1
sigs.k8s.io/gateway-api v1.0.0-rc1
sigs.k8s.io/kustomize/api v0.14.0
sigs.k8s.io/kustomize/kyaml v0.14.3
sigs.k8s.io/yaml v1.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,8 @@ k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSn
k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
sigs.k8s.io/controller-runtime v0.16.2 h1:mwXAVuEk3EQf478PQwQ48zGOXvW27UJc8NHktQVuIPU=
sigs.k8s.io/controller-runtime v0.16.2/go.mod h1:vpMu3LpI5sYWtujJOa2uPK61nB5rbwlN7BAB8aSLvGU=
sigs.k8s.io/gateway-api v0.8.1 h1:Bo4NMAQFYkQZnHXOfufbYwbPW7b3Ic5NjpbeW6EJxuU=
sigs.k8s.io/gateway-api v0.8.1/go.mod h1:0PteDrsrgkRmr13nDqFWnev8tOysAVrwnvfFM55tSVg=
sigs.k8s.io/gateway-api v1.0.0-rc1 h1:v7N9fWTcQxox5aP2IrViDw6imeUHMAt2WFjI4BYo0sw=
sigs.k8s.io/gateway-api v1.0.0-rc1/go.mod h1:+QpYENjk9s31/abu2Pv5BpK2v88UQDK2aeQCwCvy6ck=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/kind v0.20.0 h1:f0sc3v9mQbGnjBUaqSFST1dwIuiikKVGgoTwpoP33a8=
Expand Down
15 changes: 9 additions & 6 deletions internal/controllers/gateway/gateway_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"

"github.com/kong/kubernetes-ingress-controller/v2/internal/annotations"
Expand All @@ -36,7 +37,9 @@ import (
// Vars & Consts
// -----------------------------------------------------------------------------

var gatewayV1beta1Group = gatewayapi.Group(gatewayv1beta1.GroupName)
var (
gatewayV1Group = gatewayapi.Group(gatewayv1.GroupName)
)

// -----------------------------------------------------------------------------
// Gateway Controller - GatewayReconciler
Expand Down Expand Up @@ -646,8 +649,8 @@ func (r *GatewayReconciler) determineL4ListenersFromService(
addresses := make([]gatewayapi.GatewayAddress, 0, len(svc.Spec.ClusterIPs))
listeners := make([]gatewayapi.Listener, 0, len(svc.Spec.Ports))
protocolToRouteGroupKind := map[corev1.Protocol]gatewayapi.RouteGroupKind{
corev1.ProtocolTCP: {Group: &gatewayV1beta1Group, Kind: gatewayapi.Kind("TCPRoute")},
corev1.ProtocolUDP: {Group: &gatewayV1beta1Group, Kind: gatewayapi.Kind("UDPRoute")},
corev1.ProtocolTCP: {Group: &gatewayV1Group, Kind: gatewayapi.Kind("TCPRoute")},
corev1.ProtocolUDP: {Group: &gatewayV1Group, Kind: gatewayapi.Kind("UDPRoute")},
}

for _, port := range svc.Spec.Ports {
Expand Down Expand Up @@ -742,7 +745,7 @@ func (r *GatewayReconciler) determineListenersFromDataPlane(
listener.Protocol = gatewayapi.TLSProtocolType
listener.AllowedRoutes = &gatewayapi.AllowedRoutes{
Kinds: []gatewayapi.RouteGroupKind{
{Group: &gatewayV1beta1Group, Kind: (gatewayapi.Kind)("TLSRoute")},
{Group: &gatewayV1Group, Kind: (gatewayapi.Kind)("TLSRoute")},
},
}
}
Expand All @@ -752,14 +755,14 @@ func (r *GatewayReconciler) determineListenersFromDataPlane(
listener.Protocol = gatewayapi.HTTPSProtocolType
listener.AllowedRoutes = &gatewayapi.AllowedRoutes{
Kinds: []gatewayapi.RouteGroupKind{
{Group: &gatewayV1beta1Group, Kind: (gatewayapi.Kind)("HTTPRoute")},
{Group: &gatewayV1Group, Kind: (gatewayapi.Kind)("HTTPRoute")},
},
}
} else {
listener.Protocol = gatewayapi.HTTPProtocolType
listener.AllowedRoutes = &gatewayapi.AllowedRoutes{
Kinds: []gatewayapi.RouteGroupKind{
{Group: &gatewayV1beta1Group, Kind: (gatewayapi.Kind)("HTTPRoute")},
{Group: &gatewayV1Group, Kind: (gatewayapi.Kind)("HTTPRoute")},
},
}
}
Expand Down
6 changes: 3 additions & 3 deletions internal/controllers/gateway/gateway_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func TestGetReferenceGrantConditionReason(t *testing.T) {
Spec: gatewayapi.ReferenceGrantSpec{
From: []gatewayapi.ReferenceGrantFrom{
{
Group: gatewayV1beta1Group,
Group: gatewayV1Group,
Kind: "Gateway",
Namespace: "test",
},
Expand Down Expand Up @@ -468,7 +468,7 @@ func TestGetReferenceGrantConditionReason(t *testing.T) {
},
// good entry
{
Group: gatewayV1beta1Group,
Group: gatewayV1Group,
Kind: "Gateway",
Namespace: "test",
},
Expand Down Expand Up @@ -500,7 +500,7 @@ func TestGetReferenceGrantConditionReason(t *testing.T) {
Spec: gatewayapi.ReferenceGrantSpec{
From: []gatewayapi.ReferenceGrantFrom{
{
Group: gatewayV1beta1Group,
Group: gatewayV1Group,
Kind: "Gateway",
Namespace: "test",
},
Expand Down
4 changes: 2 additions & 2 deletions internal/controllers/gateway/gateway_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ func getReferenceGrantConditionReason(
}
for _, from := range grant.Spec.From {
// we are interested only in grants for gateways that want to reference secrets
if from.Group != gatewayV1beta1Group || from.Kind != "Gateway" {
if from.Group != gatewayV1Group || from.Kind != "Gateway" {
continue
}
if from.Namespace == gatewayapi.Namespace(gatewayNamespace) {
Expand Down Expand Up @@ -659,7 +659,7 @@ func routeAcceptedByGateways(routeNamespace string, parentStatuses []gatewayapi.
for _, routeParentStatus := range parentStatuses {
gatewayNamespace := routeNamespace
parentRef := routeParentStatus.ParentRef
if (parentRef.Group != nil && *parentRef.Group != gatewayV1beta1Group) ||
if (parentRef.Group != nil && *parentRef.Group != gatewayV1Group) ||
(parentRef.Kind != nil && *parentRef.Kind != "Gateway") {
continue
}
Expand Down
8 changes: 4 additions & 4 deletions internal/controllers/gateway/gateway_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import (
k8stypes "k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"

"github.com/kong/kubernetes-ingress-controller/v2/internal/gatewayapi"
"github.com/kong/kubernetes-ingress-controller/v2/internal/util/builder"
)

func init() {
if err := gatewayv1beta1.Install(scheme.Scheme); err != nil {
if err := gatewayv1.Install(scheme.Scheme); err != nil {
panic(err)
}
}
Expand Down Expand Up @@ -84,15 +84,15 @@ func TestGetListenerSupportedRouteKinds(t *testing.T) {
Kind: gatewayapi.Kind("UnknownKind"),
},
{
Group: &gatewayV1beta1Group,
Group: &gatewayV1Group,
Kind: gatewayapi.Kind("HTTPRoute"),
},
},
},
},
expectedSupportedKinds: []gatewayapi.RouteGroupKind{
{
Group: &gatewayV1beta1Group,
Group: &gatewayV1Group,
Kind: gatewayapi.Kind("HTTPRoute"),
},
},
Expand Down
12 changes: 6 additions & 6 deletions internal/controllers/gateway/route_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/client"
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"

"github.com/kong/kubernetes-ingress-controller/v2/internal/gatewayapi"
"github.com/kong/kubernetes-ingress-controller/v2/internal/util"
Expand Down Expand Up @@ -481,8 +481,8 @@ func existsMatchingReadyListenerInStatus[T gatewayapi.RouteT](route T, listener
switch any(route).(type) {
case *gatewayapi.HTTPRoute:
gvk = schema.GroupVersionKind{
Group: gatewayv1beta1.GroupVersion.Group,
Version: gatewayv1beta1.GroupVersion.Version,
Group: gatewayv1.GroupVersion.Group,
Version: gatewayv1.GroupVersion.Version,
Kind: "HTTPRoute",
}
default:
Expand Down Expand Up @@ -656,7 +656,7 @@ func isHTTPReferenceGranted(grantSpec gatewayapi.ReferenceGrantSpec, backendRef
backendRefKind = *backendRef.Kind
}
for _, from := range grantSpec.From {
if from.Group != gatewayv1beta1.GroupName || from.Kind != "HTTPRoute" || fromNamespace != string(from.Namespace) {
if from.Group != gatewayv1.GroupName || from.Kind != "HTTPRoute" || fromNamespace != string(from.Namespace) {
continue
}

Expand Down Expand Up @@ -753,7 +753,7 @@ func ensureParentsProgrammedCondition[
Namespace: lo.ToPtr(gatewayapi.Namespace(gateway.Namespace)),
Name: gatewayapi.ObjectName(gateway.Name),
Kind: lo.ToPtr(gatewayapi.Kind("Gateway")),
Group: lo.ToPtr(gatewayapi.Group(gatewayv1beta1.GroupName)),
Group: lo.ToPtr(gatewayapi.Group(gatewayv1.GroupName)),
SectionName: func() *gatewayapi.SectionName {
// We don't need to check whether the listener matches route's spec
// because that should already be done via getSupportedGatewayForRoute
Expand Down Expand Up @@ -865,7 +865,7 @@ func isParentRefEqualToParent[
parentRef gatewayapi.ParentReference,
parent parentT,
) bool {
if *parentRef.Group != gatewayv1beta1.GroupName {
if *parentRef.Group != gatewayv1.GroupName {
return false
}
if *parentRef.Kind != "Gateway" {
Expand Down
Loading

0 comments on commit 755d230

Please sign in to comment.