Skip to content

Commit

Permalink
chore: fix embedder controller
Browse files Browse the repository at this point in the history
Signed-off-by: Lanture1064 <[email protected]>
  • Loading branch information
Lanture1064 committed Nov 23, 2023
1 parent 97c97b2 commit 131df69
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions controllers/embedder_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,29 +142,31 @@ func (r *EmbedderReconciler) CheckEmbedder(ctx context.Context, logger logr.Logg

func (r *EmbedderReconciler) UpdateStatus(ctx context.Context, instance *arcadiav1alpha1.Embedder, t interface{}, err error) error {
instanceCopy := instance.DeepCopy()
var newCondition arcadiav1alpha1.Condition
if err != nil {
// Set status to unavailable
instanceCopy.Status.SetConditions(arcadiav1alpha1.Condition{
newCondition = arcadiav1alpha1.Condition{
Type: arcadiav1alpha1.TypeReady,
Status: corev1.ConditionFalse,
Reason: arcadiav1alpha1.ReasonUnavailable,
Message: err.Error(),
LastTransitionTime: metav1.Now(),
})
}
} else {
msg, ok := t.(string)
if !ok {
msg = _StatusNilResponse
}
// Set status to available
instanceCopy.Status.SetConditions(arcadiav1alpha1.Condition{
newCondition = arcadiav1alpha1.Condition{
Type: arcadiav1alpha1.TypeReady,
Status: corev1.ConditionTrue,
Reason: arcadiav1alpha1.ReasonAvailable,
Message: msg,
LastTransitionTime: metav1.Now(),
LastSuccessfulTime: metav1.Now(),
})
}
}
instanceCopy.Status.SetConditions(newCondition)
return r.Client.Status().Update(ctx, instanceCopy)
}

0 comments on commit 131df69

Please sign in to comment.