Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions internal/provider/kubernetes/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,15 @@ func (r *gatewayReconciler) subscribeAndUpdateStatus(ctx context.Context) {
NamespacedName: key,
Resource: new(gwapiv1b1.Gateway),
Mutator: status.MutatorFunc(func(obj client.Object) client.Object {
if _, ok := obj.(*gwapiv1b1.Gateway); !ok {
g, ok := obj.(*gwapiv1b1.Gateway)
if !ok {
panic(fmt.Sprintf("unsupported object type %T", obj))
}
return val.DeepCopy()
gCopy := g.DeepCopy()
gCopy.Status.Conditions = status.MergeConditions(gCopy.Status.Conditions, val.Status.Conditions...)
gCopy.Status.Addresses = val.Status.Addresses
gCopy.Status.Listeners = val.Status.Listeners
return gCopy
}),
})
}
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/kubernetes/httproute.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,15 @@ func (r *httpRouteReconciler) subscribeAndUpdateStatus(ctx context.Context) {
continue
}
key := update.Key
value := update.Value
val := update.Value
r.statusUpdater.Send(status.Update{
NamespacedName: key,
Resource: new(gwapiv1b1.HTTPRoute),
Mutator: status.MutatorFunc(func(obj client.Object) client.Object {
if _, ok := obj.(*gwapiv1b1.HTTPRoute); !ok {
panic(fmt.Sprintf("unsupported object type %T", obj))
}
return value.DeepCopy()
return val
}),
})
}
Expand Down
4 changes: 2 additions & 2 deletions internal/status/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ func computeGatewayReadyCondition(gw *gwapiv1b1.Gateway, deployment *appsv1.Depl
string(gwapiv1b1.GatewayReasonReady), message, time.Now(), gw.Generation)
}

// mergeConditions adds or updates matching conditions, and updates the transition
// MergeConditions adds or updates matching conditions, and updates the transition
// time if details of a condition have changed. Returns the updated condition array.
func mergeConditions(conditions []metav1.Condition, updates ...metav1.Condition) []metav1.Condition {
func MergeConditions(conditions []metav1.Condition, updates ...metav1.Condition) []metav1.Condition {
var additions []metav1.Condition
for i, update := range updates {
add := true
Expand Down
2 changes: 1 addition & 1 deletion internal/status/conditions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func TestMergeConditions(t *testing.T) {
fakeClock.SetTime(later)

for _, tc := range testCases {
got := mergeConditions(tc.current, tc.updates...)
got := MergeConditions(tc.current, tc.updates...)
if conditionChanged(tc.expected[0], got[0]) {
assert.Equal(t, tc.expected, got, tc.name)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/status/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

// UpdateGatewayScheduledCondition updates the status condition for the provided Gateway based on the scheduled state.
func UpdateGatewayStatusScheduledCondition(gw *gwapiv1b1.Gateway, scheduled bool) *gwapiv1b1.Gateway {
gw.Status.Conditions = mergeConditions(gw.Status.Conditions, computeGatewayScheduledCondition(gw, scheduled))
gw.Status.Conditions = MergeConditions(gw.Status.Conditions, computeGatewayScheduledCondition(gw, scheduled))
return gw
}

Expand Down Expand Up @@ -55,5 +55,5 @@ func UpdateGatewayStatusReadyCondition(gw *gwapiv1b1.Gateway, svc *corev1.Servic
gw.Status.Addresses = gwAddrs
}
// Update the ready condition.
gw.Status.Conditions = mergeConditions(gw.Status.Conditions, computeGatewayReadyCondition(gw, deployment))
gw.Status.Conditions = MergeConditions(gw.Status.Conditions, computeGatewayReadyCondition(gw, deployment))
}
2 changes: 1 addition & 1 deletion internal/status/gatewayclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import (
// SetGatewayClassAccepted inserts or updates the Accepted condition
// for the provided GatewayClass.
func SetGatewayClassAccepted(gc *gwapiv1b1.GatewayClass, accepted bool) *gwapiv1b1.GatewayClass {
gc.Status.Conditions = mergeConditions(gc.Status.Conditions, computeGatewayClassAcceptedCondition(gc, accepted))
gc.Status.Conditions = MergeConditions(gc.Status.Conditions, computeGatewayClassAcceptedCondition(gc, accepted))
return gc
}