Skip to content

Commit dcc5dfb

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 be6b09b commit dcc5dfb

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
@@ -250,16 +250,16 @@ func (r *PromotionStrategyReconciler) calculateStatus(ps *promoterv1alpha1.Promo
250250
utils.InheritNotReadyConditionFromObjects(ps, promoterConditions.ChangeTransferPolicyNotReady, ctps...)
251251
}
252252

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

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

260-
kind := reflect.TypeOf(promoterv1alpha1.ChangeTransferPolicy{}).Name()
260+
kind := reflect.TypeOf(promoterv1alpha1.PromotionStrategy{}).Name()
261261
gvk := promoterv1alpha1.GroupVersion.WithKind(kind)
262-
controllerRef := metav1.NewControllerRef(ctp, gvk)
262+
controllerRef := metav1.NewControllerRef(ps, gvk)
263263

264264
// If there is only one commit status, use the URL from that commit status.
265265
var url string
@@ -366,7 +366,7 @@ func (r *PromotionStrategyReconciler) updatePreviousEnvironmentCommitStatus(ctx
366366

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

0 commit comments

Comments
 (0)