Skip to content

Commit

Permalink
Merge pull request #263 from Lanture1064/fix-embed
Browse files Browse the repository at this point in the history
[WIP]chore: fix embedder controller
  • Loading branch information
bjwswang authored Nov 23, 2023
2 parents 3826b7f + 131df69 commit ab84641
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 ab84641

Please sign in to comment.