Skip to content

Commit 0378a21

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 1a29c94 commit 0378a21

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

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

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

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

262262
// If there is only one commit status, use the URL from that commit status.
263263
var url string
@@ -350,7 +350,7 @@ func (r *PromotionStrategyReconciler) updatePreviousEnvironmentCommitStatus(ctx
350350

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

0 commit comments

Comments
 (0)