@@ -14,7 +14,7 @@ import (
1414 "sigs.k8s.io/controller-runtime/pkg/handler"
1515 "sigs.k8s.io/controller-runtime/pkg/predicate"
1616 "sigs.k8s.io/controller-runtime/pkg/reconcile"
17- gatewayapi "sigs.k8s.io/gateway-api/apis/v1"
17+ gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
1818)
1919
2020// +kubebuilder:rbac:groups=gateway.networking.k8s.io,resources=gateways,verbs=get;list;watch;update
@@ -31,7 +31,7 @@ type GatewayReconciler struct { //nolint:revive
3131// SetupWithManager sets up the controller with the Manager.
3232func (r * GatewayReconciler ) SetupWithManager (mgr ctrl.Manager ) error {
3333 return ctrl .NewControllerManagedBy (mgr ).
34- For (& gatewayapi .Gateway {},
34+ For (& gatewayv1 .Gateway {},
3535 builder .WithPredicates (
3636 predicate .And (
3737 predicate .NewPredicateFuncs (r .matchesGatewayForControlPlaneConfig ),
@@ -40,7 +40,7 @@ func (r *GatewayReconciler) SetupWithManager(mgr ctrl.Manager) error {
4040 ),
4141 ).
4242 Watches (
43- & gatewayapi .GatewayClass {},
43+ & gatewayv1 .GatewayClass {},
4444 handler .EnqueueRequestsFromMapFunc (r .listGatewayForGatewayClass ),
4545 builder .WithPredicates (predicate .NewPredicateFuncs (r .matchesGatewayClass )),
4646 ).
@@ -50,31 +50,31 @@ func (r *GatewayReconciler) SetupWithManager(mgr ctrl.Manager) error {
5050}
5151
5252func (r * GatewayReconciler ) Reconcile (ctx context.Context , req ctrl.Request ) (ctrl.Result , error ) {
53- var gateway gatewayapi .Gateway
54- if err := r .Get (ctx , req .NamespacedName , & gateway ); err != nil {
53+ gateway := new (gatewayv1 .Gateway )
54+ if err := r .Get (ctx , req .NamespacedName , gateway ); err != nil {
5555 return ctrl.Result {}, client .IgnoreNotFound (err )
5656 }
5757
5858 condition := meta.Condition {
59- Type : string (gatewayapi .GatewayConditionAccepted ),
59+ Type : string (gatewayv1 .GatewayConditionAccepted ),
6060 Status : meta .ConditionTrue ,
61- Reason : string (gatewayapi .GatewayReasonAccepted ),
61+ Reason : string (gatewayv1 .GatewayReasonAccepted ),
6262 ObservedGeneration : gateway .Generation ,
6363 Message : acceptedMessage ("gateway" ),
6464 LastTransitionTime : meta .Now (),
6565 }
6666 if ! IsConditionPresentAndEqual (gateway .Status .Conditions , condition ) {
6767 r .Log .Info ("gateway has been accepted" , "gateway" , gateway .Name )
68- setGatewayCondition (& gateway , condition )
69- if err := r .Status ().Update (ctx , & gateway ); err != nil {
68+ setGatewayCondition (gateway , condition )
69+ if err := r .Status ().Update (ctx , gateway ); err != nil {
7070 return ctrl.Result {}, err
7171 }
7272 }
7373 return ctrl.Result {}, nil
7474}
7575
7676func (r * GatewayReconciler ) matchesGatewayClass (obj client.Object ) bool {
77- gateway , ok := obj .(* gatewayapi .GatewayClass )
77+ gateway , ok := obj .(* gatewayv1 .GatewayClass )
7878 if ! ok {
7979 r .Log .Error (fmt .Errorf ("unexpected object type" ), "failed to convert object to Gateway" )
8080 return false
@@ -83,7 +83,7 @@ func (r *GatewayReconciler) matchesGatewayClass(obj client.Object) bool {
8383}
8484
8585func (r * GatewayReconciler ) matchesGatewayForControlPlaneConfig (obj client.Object ) bool {
86- gateway , ok := obj .(* gatewayapi .Gateway )
86+ gateway , ok := obj .(* gatewayv1 .Gateway )
8787 if ! ok {
8888 r .Log .Error (fmt .Errorf ("unexpected object type" ), "failed to convert object to Gateway" )
8989 return false
@@ -97,15 +97,15 @@ func (r *GatewayReconciler) matchesGatewayForControlPlaneConfig(obj client.Objec
9797}
9898
9999func (r * GatewayReconciler ) listGatewayForGatewayClass (ctx context.Context , gatewayClass client.Object ) []reconcile.Request {
100- gatewayList := & gatewayapi .GatewayList {}
100+ gatewayList := & gatewayv1 .GatewayList {}
101101 if err := r .List (context .Background (), gatewayList ); err != nil {
102102 r .Log .Error (err , "failed to list gateways for gateway class" ,
103103 "gatewayclass" , gatewayClass .GetName (),
104104 )
105105 return nil
106106 }
107107
108- gateways := []gatewayapi .Gateway {}
108+ gateways := []gatewayv1 .Gateway {}
109109 for _ , gateway := range gatewayList .Items {
110110 if cp := config .GetControlPlaneConfigByGatewatName (gateway .GetName ()); cp != nil {
111111 gateways = append (gateways , gateway )
@@ -115,13 +115,13 @@ func (r *GatewayReconciler) listGatewayForGatewayClass(ctx context.Context, gate
115115}
116116
117117func (r * GatewayReconciler ) checkGatewayClass (obj client.Object ) bool {
118- gateway , ok := obj .(* gatewayapi .Gateway )
118+ gateway , ok := obj .(* gatewayv1 .Gateway )
119119 if ! ok {
120120 r .Log .Error (fmt .Errorf ("unexpected object type" ), "failed to convert object to Gateway" )
121121 return false
122122 }
123123
124- gatewayClass := & gatewayapi .GatewayClass {}
124+ gatewayClass := & gatewayv1 .GatewayClass {}
125125 if err := r .Client .Get (context .Background (), client.ObjectKey {Name : string (gateway .Spec .GatewayClassName )}, gatewayClass ); err != nil {
126126 r .Log .Error (err , "failed to get gateway class" , "gatewayclass" , gateway .Spec .GatewayClassName )
127127 return false
0 commit comments