Skip to content

Commit 37e96d5

Browse files
Copilotzachaller
andcommitted
Move CommitStatus ownerRef from CTP to PromotionStrategy
Changed the owner reference for previous environment CommitStatus objects from ChangeTransferPolicy (CTP) to PromotionStrategy. This aligns with the concept of PromotionStrategy being a commit status manager. - Updated createOrUpdatePreviousEnvironmentCommitStatus to accept PromotionStrategy parameter - Changed owner reference type from ChangeTransferPolicy to PromotionStrategy - Updated function call to pass PromotionStrategy instance - All 34 tests passing Co-authored-by: zachaller <[email protected]>
1 parent 9778ad2 commit 37e96d5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

internal/controller/promotionstrategy_controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,16 @@ func (r *PromotionStrategyReconciler) calculateStatus(ps *promoterv1alpha1.Promo
234234
utils.InheritNotReadyConditionFromObjects(ps, promoterConditions.ChangeTransferPolicyNotReady, ctps...)
235235
}
236236

237-
func (r *PromotionStrategyReconciler) createOrUpdatePreviousEnvironmentCommitStatus(ctx context.Context, ctp *promoterv1alpha1.ChangeTransferPolicy, phase promoterv1alpha1.CommitStatusPhase, pendingReason string, previousEnvironmentBranch string, previousCRPCSPhases []promoterv1alpha1.ChangeRequestPolicyCommitStatusPhase) (*promoterv1alpha1.CommitStatus, error) {
237+
func (r *PromotionStrategyReconciler) createOrUpdatePreviousEnvironmentCommitStatus(ctx context.Context, ps *promoterv1alpha1.PromotionStrategy, ctp *promoterv1alpha1.ChangeTransferPolicy, phase promoterv1alpha1.CommitStatusPhase, pendingReason string, previousEnvironmentBranch string, previousCRPCSPhases []promoterv1alpha1.ChangeRequestPolicyCommitStatusPhase) (*promoterv1alpha1.CommitStatus, error) {
238238
logger := log.FromContext(ctx)
239239

240240
// TODO: do we like this name proposed-<name>?
241241
csName := utils.KubeSafeUniqueName(ctx, promoterv1alpha1.PreviousEnvProposedCommitPrefixNameLabel+ctp.Name)
242242
proposedCSObjectKey := client.ObjectKey{Namespace: ctp.Namespace, Name: csName}
243243

244-
kind := reflect.TypeOf(promoterv1alpha1.ChangeTransferPolicy{}).Name()
244+
kind := reflect.TypeOf(promoterv1alpha1.PromotionStrategy{}).Name()
245245
gvk := promoterv1alpha1.GroupVersion.WithKind(kind)
246-
controllerRef := metav1.NewControllerRef(ctp, gvk)
246+
controllerRef := metav1.NewControllerRef(ps, gvk)
247247

248248
// If there is only one commit status, use the URL from that commit status.
249249
var url string
@@ -336,7 +336,7 @@ func (r *PromotionStrategyReconciler) updatePreviousEnvironmentCommitStatus(ctx
336336

337337
// Since there is at least one configured active check, and since this is not the first environment,
338338
// we should not create a commit status for the previous environment.
339-
cs, err := r.createOrUpdatePreviousEnvironmentCommitStatus(ctx, ctp, commitStatusPhase, pendingReason, previousEnvironmentStatus.Branch, ctps[i-1].Status.Active.CommitStatuses)
339+
cs, err := r.createOrUpdatePreviousEnvironmentCommitStatus(ctx, ps, ctp, commitStatusPhase, pendingReason, previousEnvironmentStatus.Branch, ctps[i-1].Status.Active.CommitStatuses)
340340
if err != nil {
341341
return fmt.Errorf("failed to create or update previous environment commit status for branch %s: %w", ctp.Spec.ActiveBranch, err)
342342
}

0 commit comments

Comments
 (0)