You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Integration**: The `generateStagesByStrategy` function now converts concrete binding arrays to interfaces before calling `computeRunStageStatus`, maintaining compatibility while enabling interface-based processing.
364
364
365
+
### Phase 8: generateStagesByStrategy Refactor ✅
366
+
367
+
**Target**: `generateStagesByStrategy` function - computes stages based on StagedUpdateStrategy
368
+
369
+
**Implementation**: Applied interface-based pattern with new strategy resolver utility:
klog.ErrorS(err, "Failed to get StagedUpdateStrategy", "stagedUpdateStrategy", updateRun.Spec.StagedUpdateStrategyName, "clusterStagedUpdateRun", updateRunRef)
307
+
308
+
// Get updateRun spec using interface methods
309
+
updateRunSpec:=updateRun.GetStagedUpdateRunSpec()
310
+
311
+
// Create NamespacedName for the StagedUpdateStrategy
312
+
// For ClusterStagedUpdateRun, namespace will be empty (cluster-scoped)
313
+
// For StagedUpdateRun, namespace will be the actual namespace (namespace-scoped)
314
+
strategyKey:= types.NamespacedName{
315
+
Name: updateRunSpec.StagedUpdateStrategyName,
316
+
Namespace: updateRun.GetNamespace(),
317
+
}
318
+
319
+
// Fetch the StagedUpdateStrategy using utility function
320
+
// This automatically determines whether to fetch ClusterStagedUpdateStrategy or StagedUpdateStrategy
klog.ErrorS(err, "Failed to get StagedUpdateStrategy", "stagedUpdateStrategy", updateRunSpec.StagedUpdateStrategyName, "stagedUpdateRun", updateRunRef)
310
324
ifapierrors.IsNotFound(err) {
311
325
// we won't continue or retry the initialization if the StagedUpdateStrategy is not found.
312
-
strategyNotFoundErr:=controller.NewUserError(errors.New("referenced clusterStagedUpdateStrategy not found: "+updateRun.Spec.StagedUpdateStrategyName))
326
+
strategyNotFoundErr:=controller.NewUserError(errors.New("referenced stagedUpdateStrategy not found: "+updateRunSpec.StagedUpdateStrategyName))
klog.V(2).InfoS("Adding a cluster to the delete stage", "cluster", binding.Spec.TargetCluster, "clusterStagedUpdateStrategy", updateStrategy.Name, "clusterStagedUpdateRun", updateRunRef)
klog.V(2).InfoS("Adding a cluster to the delete stage", "cluster", bindingSpec.TargetCluster, "stagedUpdateStrategy", updateStrategy.GetName(), "stagedUpdateRun", updateRunRef)
// FetchStagedUpdateStrategyFromNamespacedName resolves a NamespacedName to a concrete staged update strategy object that implements StagedUpdateStrategyObj.
29
+
// If Namespace is empty, it fetches a ClusterStagedUpdateStrategy (cluster-scoped).
30
+
// If Namespace is not empty, it fetches a StagedUpdateStrategy (namespace-scoped).
31
+
funcFetchStagedUpdateStrategyFromNamespacedName(ctx context.Context, c client.Reader, strategyKey types.NamespacedName) (placementv1beta1.StagedUpdateStrategyObj, error) {
0 commit comments