Skip to content

Commit

Permalink
feat: add componentplan-release label to subscription
Browse files Browse the repository at this point in the history
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
  • Loading branch information
Abirdcfly committed Nov 2, 2023
1 parent fe6f6db commit f9f90a9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion controllers/subscription_controller.go
Expand Up @@ -88,7 +88,17 @@ func (r *SubscriptionReconciler) Reconcile(ctx context.Context, req ctrl.Request
return reconcile.Result{}, utils.IgnoreNotFound(err)
}
logger.V(1).Info("Get Subscription instance")

if sub.Labels[corev1alpha1.ComponentPlanReleaseNameLabel] != sub.Spec.Name {
if sub.GetLabels() == nil {
sub.Labels = make(map[string]string)
}
sub.Labels[corev1alpha1.ComponentPlanReleaseNameLabel] = sub.Spec.Name
err = r.Update(ctx, sub)
if err != nil {
logger.Error(err, "Failed to update Subscription release label")
}
return ctrl.Result{}, err
}
// Get watched component
component := &corev1alpha1.Component{}
err = r.Get(ctx, types.NamespacedName{Namespace: sub.Spec.ComponentRef.Namespace, Name: sub.Spec.ComponentRef.Name}, component)
Expand Down

0 comments on commit f9f90a9

Please sign in to comment.