-
Notifications
You must be signed in to change notification settings - Fork 1.5k
🌱 (chore): unify init and edit subcommands into a single command struct #4776
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
base: master
Are you sure you want to change the base?
🌱 (chore): unify init and edit subcommands into a single command struct #4776
Conversation
…and struct - Replaces separate init/edit subcommands with a shared `subcommand` type - Uses dynamic scaffolder injection for each command - Adds suite and plugin tests for Grafana plugin
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: kersten The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @kersten. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
config config.Config | ||
scaffolder plugins.Scaffolder | ||
cmd string | ||
exampleDescription string | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @kersten 👋
Thanks so much for taking the time to look into this one — really appreciate your work here! 🎉
That said, I don’t think we need to introduce a new structure for this.
The init and edit commands should still go through the existing scaffolded interfaces. This helps ensure that descriptions, example snippets, and the UI behave consistently for both commands.
I believe we can follow the same pattern we used for the HelmPlugin:
https://github.com/kubernetes-sigs/kubebuilder/tree/master/pkg/plugins/optional/helm/v1alpha
In that case, the edit command simply calls into the same internal logic used by init, since they perform the same scaffolding work. For reference:
kubebuilder/pkg/plugins/optional/helm/v1alpha/edit.go
Lines 76 to 86 in 258b9c6
func (p *editSubcommand) Scaffold(fs machinery.Filesystem) error { | |
scaffolder := scaffolds.NewInitHelmScaffolder(p.config, p.force) | |
scaffolder.InjectFS(fs) | |
err := scaffolder.Scaffold() | |
if err != nil { | |
return fmt.Errorf("error scaffolding Helm chart: %w", err) | |
} | |
// Track the resources following a declarative approach | |
return insertPluginMetaToConfig(p.config, pluginConfig{}) | |
} |
It keeps the code DRY and easier to maintain while still providing a great user experience across both commands.
See:
Thanks again — looking forward to your thoughts! 🙌
"sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/grafana/v1alpha" | ||
) | ||
|
||
var _ = Describe("Grafana Plugin", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this change to achieve the intended goal?
If not, what do you think about starting with a PR that increases the Grafana plugin test coverage first? That way, we can define a clearer scope and build on top of that with more confidence.
Let me know your thoughts! 😊
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
subcommand
type