Skip to content

Commit d0c5d1c

Browse files
committed
fix test
1 parent 9e92501 commit d0c5d1c

File tree

5 files changed

+18
-45
lines changed

5 files changed

+18
-45
lines changed

internal/controller/consumer_controller.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package controller
1919

2020
import (
2121
"context"
22-
"fmt"
2322

2423
"github.com/go-logr/logr"
2524
corev1 "k8s.io/api/core/v1"
@@ -276,13 +275,9 @@ func (r *ConsumerReconciler) updateStatus(consumer *v1alpha1.Consumer, err error
276275
NamespacedName: utils.NamespacedName(consumer),
277276
Resource: consumer.DeepCopy(),
278277
Mutator: status.MutatorFunc(func(obj client.Object) client.Object {
279-
t, ok := obj.(*v1alpha1.Consumer)
280-
if !ok {
281-
err := fmt.Errorf("unsupported object type %T", obj)
282-
panic(err)
283-
}
284-
t.Status = consumer.Status
285-
return t
278+
cp := obj.(*v1alpha1.Consumer).DeepCopy()
279+
cp.Status = consumer.Status
280+
return cp
286281
}),
287282
})
288283
}

internal/controller/gatewayclass_controller.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ func (r *GatewayClassReconciler) Reconcile(ctx context.Context, req ctrl.Request
122122
Resource: gc.DeepCopy(),
123123
Mutator: status.MutatorFunc(func(obj client.Object) client.Object {
124124
cp := obj.(*gatewayv1.GatewayClass).DeepCopy()
125-
126125
cp.Status = gc.Status
127126
return cp
128127
}),

internal/controller/httproutepolicy.go

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package controller
2020
import (
2121
"cmp"
2222
"context"
23-
"fmt"
2423
"slices"
2524

2625
networkingv1 "k8s.io/api/networking/v1"
@@ -92,13 +91,9 @@ func (r *HTTPRouteReconciler) processHTTPRoutePolicies(tctx *provider.TranslateC
9291
NamespacedName: utils.NamespacedName(&policy),
9392
Resource: policy.DeepCopy(),
9493
Mutator: status.MutatorFunc(func(obj client.Object) client.Object {
95-
t, ok := obj.(*v1alpha1.HTTPRoutePolicy)
96-
if !ok {
97-
err := fmt.Errorf("unsupported object type %T", obj)
98-
panic(err)
99-
}
100-
t.Status = policy.Status
101-
return t
94+
cp := obj.(*v1alpha1.HTTPRoutePolicy).DeepCopy()
95+
cp.Status = policy.Status
96+
return cp
10297
}),
10398
})
10499
}
@@ -170,13 +165,9 @@ func (r *IngressReconciler) processHTTPRoutePolicies(tctx *provider.TranslateCon
170165
NamespacedName: utils.NamespacedName(&policy),
171166
Resource: policy.DeepCopy(),
172167
Mutator: status.MutatorFunc(func(obj client.Object) client.Object {
173-
t, ok := obj.(*v1alpha1.HTTPRoutePolicy)
174-
if !ok {
175-
err := fmt.Errorf("unsupported object type %T", obj)
176-
panic(err)
177-
}
178-
t.Status = policy.Status
179-
return t
168+
cp := obj.(*v1alpha1.HTTPRoutePolicy).DeepCopy()
169+
cp.Status = policy.Status
170+
return cp
180171
}),
181172
})
182173
}
@@ -282,13 +273,9 @@ func updateDeleteAncestors(updater status.Updater, policy v1alpha1.HTTPRoutePoli
282273
NamespacedName: utils.NamespacedName(&policy),
283274
Resource: policy.DeepCopy(),
284275
Mutator: status.MutatorFunc(func(obj client.Object) client.Object {
285-
t, ok := obj.(*v1alpha1.HTTPRoutePolicy)
286-
if !ok {
287-
err := fmt.Errorf("unsupported object type %T", obj)
288-
panic(err)
289-
}
290-
t.Status = policy.Status
291-
return t
276+
cp := obj.(*v1alpha1.HTTPRoutePolicy).DeepCopy()
277+
cp.Status = policy.Status
278+
return cp
292279
}),
293280
})
294281
}

internal/controller/ingress_controller.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -639,13 +639,9 @@ func (r *IngressReconciler) updateStatus(ctx context.Context, tctx *provider.Tra
639639
NamespacedName: utils.NamespacedName(ingress),
640640
Resource: ingress.DeepCopy(),
641641
Mutator: status.MutatorFunc(func(obj client.Object) client.Object {
642-
t, ok := obj.(*networkingv1.Ingress)
643-
if !ok {
644-
err := fmt.Errorf("unsupported object type %T", obj)
645-
panic(err)
646-
}
647-
t.Status = ingress.Status
648-
return t
642+
cp := obj.(*networkingv1.Ingress).DeepCopy()
643+
cp.Status = ingress.Status
644+
return cp
649645
}),
650646
})
651647
return nil

internal/controller/policies.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,9 @@ func ProcessBackendTrafficPolicy(
158158
NamespacedName: utils.NamespacedName(policy),
159159
Resource: policy.DeepCopy(),
160160
Mutator: status.MutatorFunc(func(obj client.Object) client.Object {
161-
t, ok := obj.(*v1alpha1.BackendTrafficPolicy)
162-
if !ok {
163-
err := fmt.Errorf("unsupported object type %T", obj)
164-
panic(err)
165-
}
166-
t.Status = policy.Status
167-
return t
161+
cp := obj.(*v1alpha1.BackendTrafficPolicy).DeepCopy()
162+
cp.Status = policy.Status
163+
return cp
168164
}),
169165
})
170166
}

0 commit comments

Comments
 (0)