Skip to content

Commit

Permalink
Inform on and use v1 Gateway API types
Browse files Browse the repository at this point in the history
Only files that set up an API client scheme or use ReferenceGrant
should have the v1beta1 import

Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
  • Loading branch information
sunjayBhatia committed Feb 12, 2024
1 parent 1a91962 commit 8dec4d0
Show file tree
Hide file tree
Showing 62 changed files with 2,829 additions and 2,852 deletions.
6 changes: 3 additions & 3 deletions cmd/contour/ingressstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
gatewayapi_v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1"

contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1"
"github.com/projectcontour/contour/internal/k8s"
Expand Down Expand Up @@ -91,7 +91,7 @@ func (isw *loadBalancerStatusWriter) Start(ctx context.Context) error {
// Only create Gateway informer if a controller or specific gateway was provided,
// otherwise the API may not exist in the cluster.
if len(isw.gatewayControllerName) > 0 || isw.gatewayRef != nil {
resources = append(resources, &gatewayapi_v1beta1.Gateway{})
resources = append(resources, &gatewayapi_v1.Gateway{})

Check warning on line 94 in cmd/contour/ingressstatus.go

View check run for this annotation

Codecov / codecov/patch

cmd/contour/ingressstatus.go#L94

Added line #L94 was not covered by tests
}

for _, r := range resources {
Expand Down Expand Up @@ -142,7 +142,7 @@ func (isw *loadBalancerStatusWriter) Start(ctx context.Context) error {
// Only list Gateways if a controller or specific gateway was configured,
// otherwise the API may not exist in the cluster.
if len(isw.gatewayControllerName) > 0 || isw.gatewayRef != nil {
var gatewayList gatewayapi_v1beta1.GatewayList
var gatewayList gatewayapi_v1.GatewayList

Check warning on line 145 in cmd/contour/ingressstatus.go

View check run for this annotation

Codecov / codecov/patch

cmd/contour/ingressstatus.go#L145

Added line #L145 was not covered by tests
if err := isw.cache.List(context.Background(), &gatewayList); err != nil {
isw.log.WithError(err).WithField("kind", "Gateway").Error("failed to list objects")
} else {
Expand Down
5 changes: 3 additions & 2 deletions cmd/contour/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
controller_runtime_metrics "sigs.k8s.io/controller-runtime/pkg/metrics"
controller_runtime_metrics_server "sigs.k8s.io/controller-runtime/pkg/metrics/server"
gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayapi_v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"

contour_v1 "github.com/projectcontour/contour/apis/projectcontour/v1"
Expand Down Expand Up @@ -1040,12 +1041,12 @@ func (s *Server) setupGatewayAPI(contourConfiguration contour_v1alpha1.ContourCo
// to process, we just need informers to get events.
case contourConfiguration.Gateway.GatewayRef != nil:
// Inform on GatewayClasses.
if err := s.informOnResource(&gatewayapi_v1beta1.GatewayClass{}, eventHandler); err != nil {
if err := s.informOnResource(&gatewayapi_v1.GatewayClass{}, eventHandler); err != nil {

Check warning on line 1044 in cmd/contour/serve.go

View check run for this annotation

Codecov / codecov/patch

cmd/contour/serve.go#L1044

Added line #L1044 was not covered by tests
s.log.WithError(err).WithField("resource", "gatewayclasses").Fatal("failed to create informer")
}

// Inform on Gateways.
if err := s.informOnResource(&gatewayapi_v1beta1.Gateway{}, eventHandler); err != nil {
if err := s.informOnResource(&gatewayapi_v1.Gateway{}, eventHandler); err != nil {

Check warning on line 1049 in cmd/contour/serve.go

View check run for this annotation

Codecov / codecov/patch

cmd/contour/serve.go#L1049

Added line #L1049 was not covered by tests
s.log.WithError(err).WithField("resource", "gateways").Fatal("failed to create informer")
}
// Otherwise, run the GatewayClass and Gateway controllers to determine
Expand Down
41 changes: 20 additions & 21 deletions internal/controller/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayapi_v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"

"github.com/projectcontour/contour/internal/k8s"
"github.com/projectcontour/contour/internal/leadership"
Expand All @@ -43,7 +42,7 @@ type gatewayReconciler struct {
statusUpdater k8s.StatusUpdater
log logrus.FieldLogger
// gatewayClassControllerName is the configured controller of managed gatewayclasses.
gatewayClassControllerName gatewayapi_v1beta1.GatewayController
gatewayClassControllerName gatewayapi_v1.GatewayController
eventSource chan event.GenericEvent
}

Expand All @@ -61,7 +60,7 @@ func RegisterGatewayController(
client: mgr.GetClient(),
eventHandler: eventHandler,
statusUpdater: statusUpdater,
gatewayClassControllerName: gatewayapi_v1beta1.GatewayController(gatewayClassControllerName),
gatewayClassControllerName: gatewayapi_v1.GatewayController(gatewayClassControllerName),
// Set up a source.Channel that will trigger reconciles
// for all GatewayClasses when this Contour process is
// elected leader, to ensure that their statuses are up
Expand All @@ -77,7 +76,7 @@ func RegisterGatewayController(
}

if err := c.Watch(
source.Kind(mgr.GetCache(), &gatewayapi_v1beta1.Gateway{}),
source.Kind(mgr.GetCache(), &gatewayapi_v1.Gateway{}),
&handler.EnqueueRequestForObject{},
predicate.NewPredicateFuncs(r.hasMatchingController),
); err != nil {
Expand All @@ -87,7 +86,7 @@ func RegisterGatewayController(
// Watch GatewayClasses and reconcile their associated Gateways
// to handle changes in the GatewayClasses' "Accepted" conditions.
if err := c.Watch(
source.Kind(mgr.GetCache(), &gatewayapi_v1beta1.GatewayClass{}),
source.Kind(mgr.GetCache(), &gatewayapi_v1.GatewayClass{}),
handler.EnqueueRequestsFromMapFunc(r.mapGatewayClassToGateways),
predicate.NewPredicateFuncs(r.gatewayClassHasMatchingController),
); err != nil {
Expand All @@ -112,7 +111,7 @@ func RegisterGatewayController(
func (r *gatewayReconciler) OnElectedLeader() {
r.log.Info("elected leader, triggering reconciles for all gateways")

var gateways gatewayapi_v1beta1.GatewayList
var gateways gatewayapi_v1.GatewayList

Check warning on line 114 in internal/controller/gateway.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gateway.go#L114

Added line #L114 was not covered by tests
if err := r.client.List(context.Background(), &gateways); err != nil {
r.log.WithError(err).Error("error listing gateways")
return
Expand All @@ -124,7 +123,7 @@ func (r *gatewayReconciler) OnElectedLeader() {
}

func (r *gatewayReconciler) mapGatewayClassToGateways(ctx context.Context, gatewayClass client.Object) []reconcile.Request {
var gateways gatewayapi_v1beta1.GatewayList
var gateways gatewayapi_v1.GatewayList

Check warning on line 126 in internal/controller/gateway.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gateway.go#L126

Added line #L126 was not covered by tests
if err := r.client.List(ctx, &gateways); err != nil {
r.log.WithError(err).Error("error listing gateways")
return nil
Expand Down Expand Up @@ -154,13 +153,13 @@ func (r *gatewayReconciler) hasMatchingController(obj client.Object) bool {
"name": obj.GetName(),
})

gw, ok := obj.(*gatewayapi_v1beta1.Gateway)
gw, ok := obj.(*gatewayapi_v1.Gateway)

Check warning on line 156 in internal/controller/gateway.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gateway.go#L156

Added line #L156 was not covered by tests
if !ok {
log.Debugf("unexpected object type %T, bypassing reconciliation.", obj)
return false
}

gc := &gatewayapi_v1beta1.GatewayClass{}
gc := &gatewayapi_v1.GatewayClass{}

Check warning on line 162 in internal/controller/gateway.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gateway.go#L162

Added line #L162 was not covered by tests
if err := r.client.Get(context.Background(), types.NamespacedName{Name: string(gw.Spec.GatewayClassName)}, gc); err != nil {
log.WithError(err).Errorf("failed to get gatewayclass %s", gw.Spec.GatewayClassName)
return false
Expand All @@ -174,7 +173,7 @@ func (r *gatewayReconciler) hasMatchingController(obj client.Object) bool {
}

func (r *gatewayReconciler) gatewayClassHasMatchingController(obj client.Object) bool {
gc, ok := obj.(*gatewayapi_v1beta1.GatewayClass)
gc, ok := obj.(*gatewayapi_v1.GatewayClass)

Check warning on line 176 in internal/controller/gateway.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gateway.go#L176

Added line #L176 was not covered by tests
if !ok {
r.log.Infof("expected GatewayClass, got %T", obj)
return false
Expand All @@ -189,13 +188,13 @@ func (r *gatewayReconciler) gatewayClassHasMatchingController(obj client.Object)
func (r *gatewayReconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) {
r.log.WithField("namespace", request.Namespace).WithField("name", request.Name).Info("reconciling gateway")

var gatewayClasses gatewayapi_v1beta1.GatewayClassList
var gatewayClasses gatewayapi_v1.GatewayClassList

Check warning on line 191 in internal/controller/gateway.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gateway.go#L191

Added line #L191 was not covered by tests
if err := r.client.List(ctx, &gatewayClasses); err != nil {
return reconcile.Result{}, fmt.Errorf("error listing gateway classes")
}

// Find the GatewayClass for this controller with Accepted=true.
var acceptedGatewayClass *gatewayapi_v1beta1.GatewayClass
var acceptedGatewayClass *gatewayapi_v1.GatewayClass

Check warning on line 197 in internal/controller/gateway.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gateway.go#L197

Added line #L197 was not covered by tests
for i := range gatewayClasses.Items {
gatewayClass := &gatewayClasses.Items[i]

Expand All @@ -212,7 +211,7 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, request reconcile.Req

if acceptedGatewayClass == nil {
r.log.Info("No accepted gateway class found")
r.eventHandler.OnDelete(&gatewayapi_v1beta1.Gateway{
r.eventHandler.OnDelete(&gatewayapi_v1.Gateway{

Check warning on line 214 in internal/controller/gateway.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gateway.go#L214

Added line #L214 was not covered by tests
ObjectMeta: meta_v1.ObjectMeta{
Namespace: request.Namespace,
Name: request.Name,
Expand All @@ -221,13 +220,13 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, request reconcile.Req
return reconcile.Result{}, nil
}

var allGateways gatewayapi_v1beta1.GatewayList
var allGateways gatewayapi_v1.GatewayList

Check warning on line 223 in internal/controller/gateway.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gateway.go#L223

Added line #L223 was not covered by tests
if err := r.client.List(ctx, &allGateways); err != nil {
return reconcile.Result{}, fmt.Errorf("error listing gateways")
}

// Get all the Gateways for the Accepted=true GatewayClass.
var gatewaysForClass []*gatewayapi_v1beta1.Gateway
var gatewaysForClass []*gatewayapi_v1.Gateway

Check warning on line 229 in internal/controller/gateway.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gateway.go#L229

Added line #L229 was not covered by tests
for i := range allGateways.Items {
if string(allGateways.Items[i].Spec.GatewayClassName) == acceptedGatewayClass.Name {
gatewaysForClass = append(gatewaysForClass, &allGateways.Items[i])
Expand All @@ -236,7 +235,7 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, request reconcile.Req

if len(gatewaysForClass) == 0 {
r.log.Info("No gateways found for accepted gateway class")
r.eventHandler.OnDelete(&gatewayapi_v1beta1.Gateway{
r.eventHandler.OnDelete(&gatewayapi_v1.Gateway{

Check warning on line 238 in internal/controller/gateway.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gateway.go#L238

Added line #L238 was not covered by tests
ObjectMeta: meta_v1.ObjectMeta{
Namespace: request.Namespace,
Name: request.Name,
Expand All @@ -247,7 +246,7 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, request reconcile.Req

// Find the oldest Gateway, using alphabetical order
// as a tiebreaker.
var oldest *gatewayapi_v1beta1.Gateway
var oldest *gatewayapi_v1.Gateway

Check warning on line 249 in internal/controller/gateway.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gateway.go#L249

Added line #L249 was not covered by tests
for _, gw := range gatewaysForClass {
switch {
case oldest == nil:
Expand All @@ -272,9 +271,9 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, request reconcile.Req
if r.statusUpdater != nil {
r.statusUpdater.Send(k8s.StatusUpdate{
NamespacedName: k8s.NamespacedNameOf(gw),
Resource: &gatewayapi_v1beta1.Gateway{},
Resource: &gatewayapi_v1.Gateway{},

Check warning on line 274 in internal/controller/gateway.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gateway.go#L274

Added line #L274 was not covered by tests
Mutator: k8s.StatusMutatorFunc(func(obj client.Object) client.Object {
gw, ok := obj.(*gatewayapi_v1beta1.Gateway)
gw, ok := obj.(*gatewayapi_v1.Gateway)

Check warning on line 276 in internal/controller/gateway.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gateway.go#L276

Added line #L276 was not covered by tests
if !ok {
panic(fmt.Sprintf("unsupported object type %T", obj))
}
Expand All @@ -300,7 +299,7 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, request reconcile.Req
return reconcile.Result{}, nil
}

func isAccepted(gatewayClass *gatewayapi_v1beta1.GatewayClass) bool {
func isAccepted(gatewayClass *gatewayapi_v1.GatewayClass) bool {

Check warning on line 302 in internal/controller/gateway.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gateway.go#L302

Added line #L302 was not covered by tests
for _, cond := range gatewayClass.Status.Conditions {
if cond.Type == string(gatewayapi_v1.GatewayClassConditionStatusAccepted) && cond.Status == meta_v1.ConditionTrue {
return true
Expand All @@ -310,7 +309,7 @@ func isAccepted(gatewayClass *gatewayapi_v1beta1.GatewayClass) bool {
return false
}

func setGatewayNotAccepted(gateway *gatewayapi_v1beta1.Gateway) *gatewayapi_v1beta1.Gateway {
func setGatewayNotAccepted(gateway *gatewayapi_v1.Gateway) *gatewayapi_v1.Gateway {

Check warning on line 312 in internal/controller/gateway.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gateway.go#L312

Added line #L312 was not covered by tests
newCond := meta_v1.Condition{
Type: string(gatewayapi_v1.GatewayConditionAccepted),
Status: meta_v1.ConditionFalse,
Expand Down
34 changes: 17 additions & 17 deletions internal/controller/gatewayclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
gatewayapi_v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1"

"github.com/projectcontour/contour/internal/k8s"
"github.com/projectcontour/contour/internal/leadership"
Expand All @@ -41,7 +41,7 @@ type gatewayClassReconciler struct {
eventHandler cache.ResourceEventHandler
statusUpdater k8s.StatusUpdater
log logrus.FieldLogger
controller gatewayapi_v1beta1.GatewayController
controller gatewayapi_v1.GatewayController
eventSource chan event.GenericEvent
}

Expand All @@ -60,7 +60,7 @@ func RegisterGatewayClassController(
eventHandler: eventHandler,
statusUpdater: statusUpdater,
log: log,
controller: gatewayapi_v1beta1.GatewayController(name),
controller: gatewayapi_v1.GatewayController(name),
// Set up a source.Channel that will trigger reconciles
// for all GatewayClasses when this Contour process is
// elected leader, to ensure that their statuses are up
Expand All @@ -78,7 +78,7 @@ func RegisterGatewayClassController(

// Only enqueue GatewayClass objects that match name.
if err := c.Watch(
source.Kind(mgr.GetCache(), &gatewayapi_v1beta1.GatewayClass{}),
source.Kind(mgr.GetCache(), &gatewayapi_v1.GatewayClass{}),
&handler.EnqueueRequestForObject{},
predicate.NewPredicateFuncs(r.hasMatchingController),
); err != nil {
Expand All @@ -99,7 +99,7 @@ func RegisterGatewayClassController(
func (r *gatewayClassReconciler) OnElectedLeader() {
r.log.Info("elected leader, triggering reconciles for all gatewayclasses")

var gatewayClasses gatewayapi_v1beta1.GatewayClassList
var gatewayClasses gatewayapi_v1.GatewayClassList

Check warning on line 102 in internal/controller/gatewayclass.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gatewayclass.go#L102

Added line #L102 was not covered by tests
if err := r.client.List(context.Background(), &gatewayClasses); err != nil {
r.log.WithError(err).Error("error listing gatewayclasses")
return
Expand All @@ -118,7 +118,7 @@ func (r *gatewayClassReconciler) hasMatchingController(obj client.Object) bool {
"name": obj.GetName(),
})

gc, ok := obj.(*gatewayapi_v1beta1.GatewayClass)
gc, ok := obj.(*gatewayapi_v1.GatewayClass)

Check warning on line 121 in internal/controller/gatewayclass.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gatewayclass.go#L121

Added line #L121 was not covered by tests
if !ok {
log.Debugf("unexpected object type %T, bypassing reconciliation.", obj)
return false
Expand All @@ -136,7 +136,7 @@ func (r *gatewayClassReconciler) hasMatchingController(obj client.Object) bool {
func (r *gatewayClassReconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) {
r.log.WithField("name", request.Name).Info("reconciling gatewayclass")

var gatewayClasses gatewayapi_v1beta1.GatewayClassList
var gatewayClasses gatewayapi_v1.GatewayClassList

Check warning on line 139 in internal/controller/gatewayclass.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gatewayclass.go#L139

Added line #L139 was not covered by tests
if err := r.client.List(ctx, &gatewayClasses); err != nil {
return reconcile.Result{}, fmt.Errorf("error listing gatewayclasses: %w", err)
}
Expand All @@ -159,7 +159,7 @@ func (r *gatewayClassReconciler) Reconcile(ctx context.Context, request reconcil
if controlledClasses.len() == 0 {
r.log.WithField("name", request.Name).Info("failed to find gatewayclass")

r.eventHandler.OnDelete(&gatewayapi_v1beta1.GatewayClass{
r.eventHandler.OnDelete(&gatewayapi_v1.GatewayClass{

Check warning on line 162 in internal/controller/gatewayclass.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gatewayclass.go#L162

Added line #L162 was not covered by tests
ObjectMeta: meta_v1.ObjectMeta{
Namespace: request.Namespace,
Name: request.Name,
Expand All @@ -168,13 +168,13 @@ func (r *gatewayClassReconciler) Reconcile(ctx context.Context, request reconcil
return reconcile.Result{}, nil
}

updater := func(gc *gatewayapi_v1beta1.GatewayClass, accepted bool) error {
updater := func(gc *gatewayapi_v1.GatewayClass, accepted bool) error {

Check warning on line 171 in internal/controller/gatewayclass.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gatewayclass.go#L171

Added line #L171 was not covered by tests
if r.statusUpdater != nil {
r.statusUpdater.Send(k8s.StatusUpdate{
NamespacedName: types.NamespacedName{Name: gc.Name},
Resource: &gatewayapi_v1beta1.GatewayClass{},
Resource: &gatewayapi_v1.GatewayClass{},

Check warning on line 175 in internal/controller/gatewayclass.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gatewayclass.go#L175

Added line #L175 was not covered by tests
Mutator: k8s.StatusMutatorFunc(func(obj client.Object) client.Object {
gwc, ok := obj.(*gatewayapi_v1beta1.GatewayClass)
gwc, ok := obj.(*gatewayapi_v1.GatewayClass)

Check warning on line 177 in internal/controller/gatewayclass.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gatewayclass.go#L177

Added line #L177 was not covered by tests
if !ok {
panic(fmt.Sprintf("unsupported object type %T", obj))
}
Expand Down Expand Up @@ -211,15 +211,15 @@ func (r *gatewayClassReconciler) Reconcile(ctx context.Context, request reconcil
// controlledClasses helps organize a list of GatewayClasses
// with the same controller string.
type controlledClasses struct {
allClasses []*gatewayapi_v1beta1.GatewayClass
oldestClass *gatewayapi_v1beta1.GatewayClass
allClasses []*gatewayapi_v1.GatewayClass
oldestClass *gatewayapi_v1.GatewayClass
}

func (cc *controlledClasses) len() int {
return len(cc.allClasses)
}

func (cc *controlledClasses) add(class *gatewayapi_v1beta1.GatewayClass) {
func (cc *controlledClasses) add(class *gatewayapi_v1.GatewayClass) {

Check warning on line 222 in internal/controller/gatewayclass.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gatewayclass.go#L222

Added line #L222 was not covered by tests
cc.allClasses = append(cc.allClasses, class)

switch {
Expand All @@ -233,12 +233,12 @@ func (cc *controlledClasses) add(class *gatewayapi_v1beta1.GatewayClass) {
}
}

func (cc *controlledClasses) acceptedClass() *gatewayapi_v1beta1.GatewayClass {
func (cc *controlledClasses) acceptedClass() *gatewayapi_v1.GatewayClass {

Check warning on line 236 in internal/controller/gatewayclass.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gatewayclass.go#L236

Added line #L236 was not covered by tests
return cc.oldestClass
}

func (cc *controlledClasses) notAcceptedClasses() []*gatewayapi_v1beta1.GatewayClass {
var res []*gatewayapi_v1beta1.GatewayClass
func (cc *controlledClasses) notAcceptedClasses() []*gatewayapi_v1.GatewayClass {
var res []*gatewayapi_v1.GatewayClass

Check warning on line 241 in internal/controller/gatewayclass.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/gatewayclass.go#L240-L241

Added lines #L240 - L241 were not covered by tests
for _, gc := range cc.allClasses {
// skip the oldest one since it will be accepted.
if gc.Name != cc.oldestClass.Name {
Expand Down
8 changes: 4 additions & 4 deletions internal/controller/httproute.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
gatewayapi_v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1"
)

type httpRouteReconciler struct {
Expand All @@ -51,15 +51,15 @@ func RegisterHTTPRouteController(log logrus.FieldLogger, mgr manager.Manager, ev
return err
}

return c.Watch(source.Kind(mgr.GetCache(), &gatewayapi_v1beta1.HTTPRoute{}), &handler.EnqueueRequestForObject{})
return c.Watch(source.Kind(mgr.GetCache(), &gatewayapi_v1.HTTPRoute{}), &handler.EnqueueRequestForObject{})
}

func (r *httpRouteReconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) {
// Fetch the HTTPRoute from the cache.
httpRoute := &gatewayapi_v1beta1.HTTPRoute{}
httpRoute := &gatewayapi_v1.HTTPRoute{}

Check warning on line 59 in internal/controller/httproute.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/httproute.go#L59

Added line #L59 was not covered by tests
err := r.client.Get(ctx, request.NamespacedName, httpRoute)
if errors.IsNotFound(err) {
r.eventHandler.OnDelete(&gatewayapi_v1beta1.HTTPRoute{
r.eventHandler.OnDelete(&gatewayapi_v1.HTTPRoute{

Check warning on line 62 in internal/controller/httproute.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/httproute.go#L62

Added line #L62 was not covered by tests
ObjectMeta: meta_v1.ObjectMeta{
Name: request.Name,
Namespace: request.Namespace,
Expand Down
4 changes: 2 additions & 2 deletions internal/dag/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

"github.com/prometheus/client_golang/prometheus"
"k8s.io/apimachinery/pkg/types"
gatewayapi_v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1"

"github.com/projectcontour/contour/internal/k8s"
"github.com/projectcontour/contour/internal/metrics"
Expand Down Expand Up @@ -61,7 +61,7 @@ func (b *Builder) Build() *DAG {
if b.Source.gateway != nil {
gatewayNSName = k8s.NamespacedNameOf(b.Source.gateway)
}
var gatewayController gatewayapi_v1beta1.GatewayController
var gatewayController gatewayapi_v1.GatewayController
if b.Source.gatewayclass != nil {
gatewayController = b.Source.gatewayclass.Spec.ControllerName
}
Expand Down
Loading

0 comments on commit 8dec4d0

Please sign in to comment.