Skip to content

Commit 402fe8f

Browse files
committed
feat: add componentplan-release label to subscription
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
1 parent fe6f6db commit 402fe8f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

controllers/subscription_controller.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,17 @@ func (r *SubscriptionReconciler) Reconcile(ctx context.Context, req ctrl.Request
8888
return reconcile.Result{}, utils.IgnoreNotFound(err)
8989
}
9090
logger.V(1).Info("Get Subscription instance")
91-
91+
if sub.Labels[corev1alpha1.ComponentPlanReleaseNameLabel] != sub.Spec.Name {
92+
if sub.GetLabels() == nil {
93+
sub.Labels = make(map[string]string)
94+
}
95+
sub.Labels[corev1alpha1.ComponentPlanReleaseNameLabel] = sub.Spec.Name
96+
err = r.Update(ctx, sub)
97+
if err != nil {
98+
logger.Error(err, "Failed to update Subscription release label")
99+
}
100+
return ctrl.Result{Requeue: true}, err
101+
}
92102
// Get watched component
93103
component := &corev1alpha1.Component{}
94104
err = r.Get(ctx, types.NamespacedName{Namespace: sub.Spec.ComponentRef.Namespace, Name: sub.Spec.ComponentRef.Name}, component)

0 commit comments

Comments
 (0)