Skip to content

[SDK] Allow users to set nothing config for the plugin in the app.pipecd.yaml#5937

Merged
t-kikuc merged 4 commits into
masterfrom
set-default-value-and-validation-for-empty-config
Jun 11, 2025
Merged

[SDK] Allow users to set nothing config for the plugin in the app.pipecd.yaml#5937
t-kikuc merged 4 commits into
masterfrom
set-default-value-and-validation-for-empty-config

Conversation

@ffjlabo
Copy link
Copy Markdown
Member

@ffjlabo ffjlabo commented Jun 11, 2025

What this PR does:

as ttile

Why we need it:

There is a case when users deploy without any plugin config in app.pipecd.yaml.

Which issue(s) this PR fixes:

Follow #5922

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: Yoshiki Fujikane <ffjlabo@gmail.com>
@github-actions github-actions Bot added area/go area/plugin-sdk piped-plugin-sdk labels Jun 11, 2025
@ffjlabo ffjlabo changed the title Allaw users to set nothing config for the plugin in the app.pipecd.yaml [SDK] Allaw users to set nothing config for the plugin in the app.pipecd.yaml Jun 11, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 28.51%. Comparing base (6c01542) to head (5f2f453).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5937      +/-   ##
==========================================
+ Coverage   28.47%   28.51%   +0.03%     
==========================================
  Files         520      517       -3     
  Lines       56416    55929     -487     
==========================================
- Hits        16066    15946     -120     
+ Misses      39083    38724     -359     
+ Partials     1267     1259       -8     
Flag Coverage Δ
. 23.76% <ø> (ø)
.-pkg-app-pipedv1-plugin-example 0.00% <ø> (ø)
.-pkg-app-pipedv1-plugin-kubernetes 66.42% <ø> (ø)
.-pkg-app-pipedv1-plugin-kubernetes_multicluster 67.51% <ø> (ø)
.-pkg-app-pipedv1-plugin-wait 35.51% <ø> (ø)
.-pkg-plugin-sdk 49.22% <100.00%> (+0.19%) ⬆️
.-tool-actions-gh-release 19.23% <ø> (ø)
.-tool-actions-plan-preview ?
.-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.

@ffjlabo ffjlabo marked this pull request as ready for review June 11, 2025 02:50
@ffjlabo ffjlabo requested a review from a team as a code owner June 11, 2025 02:50
Comment thread pkg/plugin/sdk/deployment_source.go Outdated
// Set the Spec to the zero value of the spec type to avoid nil pointer dereference.
c.Spec = new(Spec)
return nil
// It is necessary to prepare config with default value when users doesn't set any config.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's not only default config but also custom unmarshalling logic.
The point is to call json.Unmarshal to invoke custom unmarshalling logic.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@Warashi
Thank you for the commnet. I fixed the comment.
Is it ok?
01b8d51

Comment thread pkg/plugin/sdk/deployment_source.go Outdated

// Validate the spec if it implements the Validate method.
if v, ok := any(spec).(interface{ Validate() error }); ok {
if v, ok := any(&spec).(interface{ Validate() error }); ok {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this the same as just below?
parsePluginConfig checks both Spec and *Spec are implement Validate() error.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's a mistake. Thanks, fixed on b5c2fa2

@t-kikuc t-kikuc changed the title [SDK] Allaw users to set nothing config for the plugin in the app.pipecd.yaml [SDK] Allow users to set nothing config for the plugin in the app.pipecd.yaml Jun 11, 2025
ffjlabo added 2 commits June 11, 2025 12:07
Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com>
Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com>
@ffjlabo ffjlabo requested a review from Warashi June 11, 2025 03:13
Comment thread pkg/plugin/sdk/deployment_source.go Outdated
// Set the Spec to the zero value of the spec type to avoid nil pointer dereference.
c.Spec = new(Spec)
return nil
// It is necessary to prepare config with default value when users doesn't set any config, or when developers implements custom unmarshalling logic.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[nit] to clarify

Suggested change
// It is necessary to prepare config with default value when users doesn't set any config, or when developers implements custom unmarshalling logic.
// It is necessary to prepare config with default value when users don't set any config, or when plugin developers implement custom unmarshalling logic.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, fixed 5f2f453

Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com>
@ffjlabo ffjlabo requested a review from t-kikuc June 11, 2025 03:27
Copy link
Copy Markdown
Member

@t-kikuc t-kikuc left a comment

Choose a reason for hiding this comment

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

Thank you

@t-kikuc t-kikuc enabled auto-merge (squash) June 11, 2025 03:37
Copy link
Copy Markdown
Member

@Warashi Warashi left a comment

Choose a reason for hiding this comment

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

LGTM

@t-kikuc t-kikuc merged commit d73300d into master Jun 11, 2025
40 checks passed
@t-kikuc t-kikuc deleted the set-default-value-and-validation-for-empty-config branch June 11, 2025 04:00
@github-actions github-actions Bot mentioned this pull request Jul 14, 2025
@github-actions github-actions Bot mentioned this pull request Aug 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants