Skip to content

Commit d471283

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 4660ac3 commit d471283

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
@@ -315,16 +315,16 @@ func (r *PromotionStrategyReconciler) calculateStatus(ps *promoterv1alpha1.Promo
315315
utils.InheritNotReadyConditionFromObjects(ps, promoterConditions.ChangeTransferPolicyNotReady, ctps...)
316316
}
317317

318-
func (r *PromotionStrategyReconciler) createOrUpdatePreviousEnvironmentCommitStatus(ctx context.Context, ctp *promoterv1alpha1.ChangeTransferPolicy, phase promoterv1alpha1.CommitStatusPhase, pendingReason string, previousEnvironmentBranch string, previousCRPCSPhases []promoterv1alpha1.ChangeRequestPolicyCommitStatusPhase) (*promoterv1alpha1.CommitStatus, error) {
318+
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) {
319319
logger := log.FromContext(ctx)
320320

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

325-
kind := reflect.TypeOf(promoterv1alpha1.ChangeTransferPolicy{}).Name()
325+
kind := reflect.TypeOf(promoterv1alpha1.PromotionStrategy{}).Name()
326326
gvk := promoterv1alpha1.GroupVersion.WithKind(kind)
327-
controllerRef := metav1.NewControllerRef(ctp, gvk)
327+
controllerRef := metav1.NewControllerRef(ps, gvk)
328328

329329
// If there is only one commit status, use the URL from that commit status.
330330
var url string
@@ -431,7 +431,7 @@ func (r *PromotionStrategyReconciler) updatePreviousEnvironmentCommitStatus(ctx
431431

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

0 commit comments

Comments
 (0)