Skip to content

[Plugin SDK] Implement another way to create plugin #5698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 26, 2025

Conversation

Warashi
Copy link
Member

@Warashi Warashi commented Mar 26, 2025

What this PR does:

as title

Why we need it:

In #5693, I wanted to remove the duplicated Name() and Version() definitions in the Kubernetes plugin.
It's easy to remove the duplication in the k8s plugin only, but it's better to provide a way to implement plugins without requiring the Name() and Version() methods in multiple interfaces.
I noticed that we can provide the way that requires name and version as positional arguments when creating a plugin.
In this way, the plugin implementations are passed as the Functional Options Pattern to the plugin constructor function.
Additionally, we can implement assertions to the constructor function to provide helpful errors.

Which issue(s) this PR fixes:

Part of #5530

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):

Warashi added 2 commits March 26, 2025 09:24
Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]>
Copy link

codecov bot commented Mar 26, 2025

Codecov Report

Attention: Patch coverage is 0% with 199 lines in your changes missing coverage. Please review.

Project coverage is 25.66%. Comparing base (dca04f9) to head (62dab3b).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
pkg/plugin/sdk/plugin.go 0.00% 199 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5698      +/-   ##
==========================================
- Coverage   25.76%   25.66%   -0.11%     
==========================================
  Files         480      481       +1     
  Lines       51045    51244     +199     
==========================================
  Hits        13151    13151              
- Misses      36896    37095     +199     
  Partials      998      998              

☔ 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.

Copy link
Member

@ffjlabo ffjlabo left a comment

Choose a reason for hiding this comment

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

LGTM

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