kubernetes-sigs / kubebuilder-declarative-pattern

A toolkit for building declarative operators with kubebuilder
Apache License 2.0
254 stars 84 forks source link

WIP - KB declarative pattern external plugin #300

Closed em-r closed 2 months ago

em-r commented 1 year ago

What this PR does / why we need it: This PR copies the code of the declarative pattern plugin from kubebuilder to kubebuilder-declarative-pattern, as part of the ongoing effort to decouple the development of the plugin from the development of Kubebuilder now that Kubebuilder supports external plugins.

Which issue(s) this PR fixes:

Fixes #293

Special notes for your reviewer: Work done so far:

Remaining items:

Additional documentation:

k8s-ci-robot commented 1 year ago

Welcome @em-r!

It looks like this is your first PR to kubernetes-sigs/kubebuilder-declarative-pattern 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kubebuilder-declarative-pattern has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. :smiley:

k8s-ci-robot commented 1 year ago

Hi @em-r. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
em-r commented 1 year ago

cc @justinsb @camilamacedo86 I've left a summary of the work done so far on the PR description. Thanks!

k8s-ci-robot commented 1 year ago

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: em-r Once this PR has been reviewed and has the lgtm label, please assign atoato88 for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files: - **[OWNERS](https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern/blob/master/OWNERS)** Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
em-r commented 1 year ago

due to how Kubebuilder doesn't propagate project config on init command, but rather injects it in PluginRequest.Universe as part of PROJECT file in subsequent commands (e.g. create api), when externalizing declarative plugin, only one of the existing go plugins (e.g. go/v4, go/v3) can be supported for performing scaffolding. So to support scaffolds with different versions of go plugin, https://github.com/kubernetes-sigs/kubebuilder/issues/3245 needs to be resolved by adding support for injecting project config into external plugins, similar to how it's done for plugins that are builtin to Kubebuilder. cc @camilamacedo86

camilamacedo86 commented 1 year ago

Hi @em-r,

The https://github.com/kubernetes-sigs/kubebuilder/issues/3245 is sorted out and available in the latest release 3.10. have we any other blocker to move forward within?

em-r commented 1 year ago

Hi @camilamacedo86, thank you for following up on this. I have just upgraded Kubebuilder locally to 3.10.0, however, I still couldn't find a way to access the project config or the layout via the input (e.g. PluginRequest) passed from Kubebuilder to the external plugin, could you please share with me how I can get access to one of those?

To recap: the problem is that the declarative plugin needs to know if the project is being scaffolded with go/v4 or go/v3 so that it can perform correct scaffolding around Dockerfile in the init subcommand. and unfortunately, when the init subcommand is running, the PROJECT file won't exist at that point so extracting the layout from it won't be an option, which leads me to think that we need to either "inject" the config (the way we do with internal plugins) through the PluginRequest input.

camilamacedo86 commented 1 year ago

Hi @em-r,

em-r commented last week Hi @camilamacedo86, thank you for following up on this. I have just upgraded Kubebuilder locally to 3.10.0, however, I still couldn't find a way to access the project config or the layout via the input (e.g. PluginRequest) passed from Kubebuilder to the external plugin, could you please share with me how I can get access to one of those?

To recap: the problem is that the declarative plugin needs to know if the project is being scaffolded with go/v4 or go/v3 so that it can perform correct scaffolding around Dockerfile in the init subcommand. and unfortunately, when the init subcommand is running, the PROJECT file won't exist at that point so extracting the layout from it won't be an option, which leads me to think that we need to either "inject" the config (the way we do with internal plugins) through the PluginRequest input.

The plugin go/v3 is deprecated. Therefore, I would strongly say that this plugin should only cares about go/v4 layout. Therefore, the initial version should NOT care about or address this implementation. This complexity is sorted out.

However, to improve the Kubebuilder API for future needs, I tracked the issue: https://github.com/kubernetes-sigs/kubebuilder/issues/3396

k8s-triage-robot commented 7 months ago

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

camilamacedo86 commented 7 months ago

/remove-lifecycle stale

k8s-triage-robot commented 4 months ago

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot commented 3 months ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot commented 2 months ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

k8s-ci-robot commented 2 months ago

@k8s-triage-robot: Closed this PR.

In response to [this](https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern/pull/300#issuecomment-2172357212): >The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. > >This bot triages PRs according to the following rules: >- After 90d of inactivity, `lifecycle/stale` is applied >- After 30d of inactivity since `lifecycle/stale` was applied, `lifecycle/rotten` is applied >- After 30d of inactivity since `lifecycle/rotten` was applied, the PR is closed > >You can: >- Reopen this PR with `/reopen` >- Mark this PR as fresh with `/remove-lifecycle rotten` >- Offer to help out with [Issue Triage][1] > >Please send feedback to sig-contributor-experience at [kubernetes/community](https://github.com/kubernetes/community). > >/close > >[1]: https://www.kubernetes.dev/docs/guide/issue-triage/ Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.