Skip to content

[Multi_K8s-Plugin] Extract duplicated target-building pattern into shared helpers#6782

Open
mohammedfirdouss wants to merge 2 commits into
pipe-cd:masterfrom
mohammedfirdouss:feat/refactor-stage-boilerplate
Open

[Multi_K8s-Plugin] Extract duplicated target-building pattern into shared helpers#6782
mohammedfirdouss wants to merge 2 commits into
pipe-cd:masterfrom
mohammedfirdouss:feat/refactor-stage-boilerplate

Conversation

@mohammedfirdouss
Copy link
Copy Markdown
Contributor

@mohammedfirdouss mohammedfirdouss commented May 17, 2026

What this PR does:
Extracts the repeated ~45-line target-resolution and errgroup pattern from the four stage entry-point functions (executeK8sMultiSyncStage, executeK8sMultiCanaryRolloutStage, executeK8sMultiBaselineRolloutStage, executeK8sMultiPrimaryRolloutStage) into two package-level helpers in a new file deployment/targets.go:

  • buildStageTargets(lp, dts, multiTargets) resolves which deploy targets a stage should run on (all targets if multiTargets is empty, or the named subset)
  • runOnTargets(ctx, lp, targets, fn) fans out fn across targets in parallel via errgroup

Why we need it:
All four rollout/sync entry-point functions contained identical boilerplate: build a deploy-target map, resolve the target list, fan out with errgroup, handle errors. Any bug fix or behaviour change had to be applied in four places. The helpers eliminate the duplication while keeping behaviour identical.

Which issue(s) this PR fixes:

Fixes #6446

Does this PR introduce a user-facing change?:

  • How are users affected by this change: No user-facing change. Just internal refactor identical behaviour.
  • Is this breaking change: No
  • How to migrate (if breaking change): N/A

… and errgroup pattern into shared helpers

Signed-off-by: Mohammed Firdous <124298708+mohammedfirdouss@users.noreply.github.com>
@mohammedfirdouss mohammedfirdouss force-pushed the feat/refactor-stage-boilerplate branch from aef9158 to 6d3dc39 Compare May 17, 2026 07:52
@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 36.57%. Comparing base (5df1ef3) to head (6d3dc39).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6782      +/-   ##
==========================================
+ Coverage   29.33%   36.57%   +7.24%     
==========================================
  Files         598       63     -535     
  Lines       63902     5889   -58013     
==========================================
- Hits        18744     2154   -16590     
+ Misses      43711     3622   -40089     
+ Partials     1447      113    -1334     
Flag Coverage Δ
. ?
.-pkg-app-pipedv1-plugin-analysis ?
.-pkg-app-pipedv1-plugin-ecs 31.82% <ø> (ø)
.-pkg-app-pipedv1-plugin-kubernetes ?
.-pkg-app-pipedv1-plugin-kubernetes_multicluster ?
.-pkg-app-pipedv1-plugin-scriptrun 54.83% <ø> (ø)
.-pkg-app-pipedv1-plugin-terraform ?
.-pkg-app-pipedv1-plugin-wait 33.04% <ø> (ø)
.-pkg-app-pipedv1-plugin-waitapproval 52.71% <ø> (ø)
.-pkg-plugin-sdk 50.34% <ø> (ø)
.-tool-actions-gh-release 19.23% <ø> (ø)
.-tool-actions-plan-preview 25.51% <ø> (ø)
.-tool-codegen-protoc-gen-auth 0.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[LFX Mentorship T-1 2026] Kubernetes Multi-Cluster Plugin #6446

1 participant