Skip to content

Docs V1: Add plugin tutorial Chapter 5 - Building sync stages - #7154

Open
rahulshendre wants to merge 3 commits into
pipe-cd:masterfrom
rahulshendre:docs/plugin-book-ch5
Open

Docs V1: Add plugin tutorial Chapter 5 - Building sync stages#7154
rahulshendre wants to merge 3 commits into
pipe-cd:masterfrom
rahulshendre:docs/plugin-book-ch5

Conversation

@rahulshendre

Copy link
Copy Markdown
Contributor

What this PR does:
Adds chapter 5 of the creating a plugin tutorial, majorly covers how to implement the BuildPipelineSyncStages and BuildQuickSyncStages

Why we need it:
5th chapter of the tutorial

Which issue(s) this PR fixes:

Part of #6679

Does this PR introduce a user-facing change?:

  • How are users affected by this change:
  • Is this breaking change:
  • How to migrate (if breaking change):

Signed-off-by: rahulshendre <rahulshendre789@gmail.com>
@khanhtc1202

Copy link
Copy Markdown
Member

@mohammedfirdouss @armistcxy could you help me check this docs 👀

return nil, fmt.Errorf("no stages defined in the request")
}

stages := make([]sdk.PipelineStage, 0, len(input.Request.Stages)+1)

@armistcxy armistcxy Aug 23, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comment to explain why +1

Suggest: "+1 leaves room for the rollback stage without a second allocation" and remove L60

}
}

if input.Request.Rollback {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also add comment to explain this part

Suggest: Rollback restores our changes before any of our later stages run so it shares the smallest index among the requested stages

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment here, though I tweaked the wording slightly... digging into planner.go, piped appends all rollback stages after the normal ones and only uses this index to order them across plugins, so I framed it that way rather than "before our later stages", also reworded the bullet above to match.
Good catch, this spot is what made me re-check the planner, thanks @armistcxy : )

@armistcxy armistcxy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @rahulshendre , everything looks good overall

There are a few places where I think we could make things better. Perhaps you could consider them

Copilot AI lite review requested due to automatic review settings August 23, 2026 07:29
@netlify

netlify Bot commented Aug 23, 2026

Copy link
Copy Markdown

Deploy Preview for pipecd-site ready!

Name Link
🔨 Latest commit f97c7ad
🔍 Latest deploy log https://app.netlify.com/projects/pipecd-site/deploys/6a8ae1edc4b1d20008ce8970
😎 Deploy Preview https://deploy-preview-7154--pipecd-site.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 36.03%. Comparing base (69545ec) to head (8377221).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7154      +/-   ##
==========================================
+ Coverage   29.74%   36.03%   +6.28%     
==========================================
  Files         601      100     -501     
  Lines       64408     8548   -55860     
==========================================
- Hits        19158     3080   -16078     
+ Misses      43758     5298   -38460     
+ Partials     1492      170    -1322     
Flag Coverage Δ
. ?
.-pkg-app-pipedv1-plugin-analysis 32.16% <ø> (ø)
.-pkg-app-pipedv1-plugin-ecs 33.64% <ø> (ø)
.-pkg-app-pipedv1-plugin-kubernetes ?
.-pkg-app-pipedv1-plugin-kubernetes_multicluster ?
.-pkg-app-pipedv1-plugin-scriptrun 54.83% <ø> (ø)
.-pkg-app-pipedv1-plugin-terraform 38.46% <ø> (ø)
.-pkg-app-pipedv1-plugin-wait 33.04% <ø> (ø)
.-pkg-app-pipedv1-plugin-waitapproval 52.71% <ø> (ø)
.-pkg-plugin-sdk 49.85% <ø> (ø)
.-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 Harness.
📢 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Chapter 5 to the Docs V1 “creating a plugin” tutorial, focusing on how a plugin plans stages for pipeline sync vs quick sync in PipeCD’s plugin SDK.

Changes:

  • Introduces a new tutorial chapter explaining BuildPipelineSyncStages and BuildQuickSyncStages.
  • Provides example implementations (including rollback handling) and notes on required imports.
  • Adds build verification guidance (go build ./...) for the tutorial’s code.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Signed-off-by: rahulshendre <rahulshendre789@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Suppressed comments (2)

Previously missed (1) — in code that hasn't changed since the last review.

docs/content/en/docs-v1.0.x/plugins/creating-a-plugin/chapter-05-building-sync-stages.md:13

  • This sentence implies piped passes the entire application pipeline to the plugin, but the planner groups stages by stage name and calls each plugin with only the stage configs that belong to that plugin (indexes remain the original pipeline positions). Clarifying this avoids confusion when users have multi-plugin pipelines.
`piped` calls `BuildPipelineSyncStages` for a pipeline sync deployment. It passes the stages the user defined in the application's pipeline, and the plugin returns the stage list `piped` runs.

docs/content/en/docs-v1.0.x/plugins/creating-a-plugin/chapter-05-building-sync-stages.md:104

  • Same issue here: sdk.ConfigNone is already a pointer alias, so this should not be *sdk.ConfigNone (otherwise the example becomes **struct{} and won’t compile).
func (p *plugin) BuildQuickSyncStages(ctx context.Context, _ *sdk.ConfigNone, input *sdk.BuildQuickSyncStagesInput) (*sdk.BuildQuickSyncStagesResponse, error) {

Replace the empty method with the following:

```go
func (p *plugin) BuildPipelineSyncStages(ctx context.Context, _ *sdk.ConfigNone, input *sdk.BuildPipelineSyncStagesInput) (*sdk.BuildPipelineSyncStagesResponse, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rahulshendre no worry, this is false alert :)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proof that still can compile: https://go.dev/play/p/JiU8j0GveNl

@armistcxy armistcxy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now

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.

4 participants