Skip to content

πŸ› Allow 'kubebuilder alpha generate' rescaffolds work with no longer supported/available plugins ( go/v3 and go/v2 ) #4572

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 1 commit into from
Mar 18, 2025

Conversation

sarthaksarthak9
Copy link
Member

@sarthaksarthak9 sarthaksarthak9 commented Feb 21, 2025

Fixes: #4433

  • Fixed issue where 'kubebuilder alpha generate' failed if PROJECT contained go.kubebuilder.io/v3.
  • Automatically updates outdated plugin references (v2, v3 β†’ v4) to support scaffolding.
  • Added a warning to notify users before modifying the PROJECT file.
  • Added test to validate changes automatically

image


image


image

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 21, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @sarthaksarthak9. 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. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 21, 2025
@sarthaksarthak9 sarthaksarthak9 changed the title (:sparkles:) Ensure 'kubebuilder alpha generate' rescaffolds with outdated plugins (:sparkles:): Ensure 'kubebuilder alpha generate' rescaffolds with outdated plugins Feb 21, 2025
@sarthaksarthak9 sarthaksarthak9 changed the title (:sparkles:): Ensure 'kubebuilder alpha generate' rescaffolds with outdated plugins (:sparkles:)Ensure 'kubebuilder alpha generate' rescaffolds with outdated plugins Feb 21, 2025
@sarthaksarthak9 sarthaksarthak9 changed the title (:sparkles:)Ensure 'kubebuilder alpha generate' rescaffolds with outdated plugins ✨ Ensure 'kubebuilder alpha generate' rescaffolds with outdated plugins Feb 21, 2025
Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

Really great job πŸ₯‡ πŸŽ‰
I added some comments, and I think we need to add a test for this case.
Otherwise, it is all amazing !!!

@sarthaksarthak9
Copy link
Member Author

sarthaksarthak9 commented Feb 22, 2025

@camilamacedo86 I noticed that updating the plugin list in getInitArgs() automatically updates the PROJECT file, even though I don’t explicitly see a save function. How is this happening? Could you help me confirm where the file update is triggered?. Also, is there still a need for updateProjectFileForAlphaGenerate() in this case?

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 25, 2025
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 26, 2025
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 26, 2025
@camilamacedo86
Copy link
Member

camilamacedo86 commented Mar 13, 2025

Hi @sarthaksarthak9

@camilamacedo86 could you pls review the changes ?

Thank you a lot for your contribution, but it's still not working.
Did you try test it locally? See my comment with the steps at: #4572 (comment)

Following my latest test (done today):

 $ make install
go build -ldflags " -X sigs.k8s.io/kubebuilder/v4/cmd.kubeBuilderVersion=v4.5.0-75-g7dc69ec18 -X sigs.k8s.io/kubebuilder/v4/cmd.goos=darwin -X sigs.k8s.io/kubebuilder/v4/cmd.goarch=arm64 -X sigs.k8s.io/kubebuilder/v4/cmd.gitCommit=7dc69ec1870460375e2d28f28aeeeb3854cfa59f -X sigs.k8s.io/kubebuilder/v4/cmd.buildDate=2025-03-13T16:30:31Z " -o bin/kubebuilder
rm -f /Users/camilam/go/bin/kubebuilder
cp ./bin/kubebuilder /Users/camilam/go/bin/kubebuilder

cd testdata/project-v4
$ vim PROJECT (I edit to be v3)

$ kubebuilder alpha generate
Error: no plugin could be resolved with key "go.kubebuilder.io/v3" for project version "3"
Usage:
  kubebuilder [flags]

Examples:
The first step is to initialize your project:
    kubebuilder init [--plugins=<PLUGIN KEYS> [--project-version=<PROJECT VERSION>]]

<PLUGIN KEYS> is a comma-separated list of plugin keys from the following table
and <PROJECT VERSION> a supported project version for these plugins.

                             Plugin keys | Supported project versions
-----------------------------------------+----------------------------
               base.go.kubebuilder.io/v4 |                          3
 deploy-image.go.kubebuilder.io/v1-alpha |                          3
                    go.kubebuilder.io/v4 |                          3
         grafana.kubebuilder.io/v1-alpha |                          3
            helm.kubebuilder.io/v1-alpha |                          3
      kustomize.common.kubebuilder.io/v2 |                          3

For more specific help for the init command of a certain plugins and project version
configuration please run:
    kubebuilder init --help --plugins=<PLUGIN KEYS> [--project-version=<PROJECT VERSION>]

Default plugin keys: "go.kubebuilder.io/v4"
Default project version: "3"


Flags:
  -h, --help                     help for kubebuilder
      --plugins strings          plugin keys to be used for this subcommand execution
      --project-version string   project version (default "3")

FATA no plugin could be resolved with key "go.kubebuilder.io/v3" for project version "3" 

Did you push all your changes?

@sarthaksarthak9
Copy link
Member Author

@camilamacedo86 Apologies for the oversight! I only had updated the description with the output earlier but forgot to push the changes. Changes are working I tested it locally.

Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

Hi @sarthaksarthak9,

Thank you so much for your contribution! I think something might be missing from your previous work because, when I tested your changes locally, it still didn’t work as expected.

What do you think about adding tests to ensure this scenario is automatically validated? See: #4572 (comment)

Looking forward to your thoughts!

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 17, 2025
@camilamacedo86 camilamacedo86 changed the title ✨ Ensure 'kubebuilder alpha generate' rescaffolds with outdated plugins πŸ› Allow 'kubebuilder alpha generate' rescaffolds work with no longer supported/available plugins ( go/v3 and go/v2 ) Mar 17, 2025
@camilamacedo86
Copy link
Member

Hi @sarthaksarthak9,

Thank you so much for working on this fix!
The test will help us validate that everything is working correctly.

Also, I hope you don’t mind, but I updated the title because we use the emoji and description to generate the release notes. Since it’s a bug, I just tried to clarify it a bit better.

Thanks again!

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 17, 2025
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 17, 2025
Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve
/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 18, 2025
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 18, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86, sarthaksarthak9

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 18, 2025
@camilamacedo86
Copy link
Member

/test pull-kubebuilder-e2e-k8s-1-30-8

@k8s-ci-robot k8s-ci-robot merged commit 3f4d5f4 into kubernetes-sigs:master Mar 18, 2025
23 checks passed
@sarthaksarthak9 sarthaksarthak9 deleted the alpha branch March 18, 2025 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubebuilder alpha generate fails to rescaffold if PROJECT contains go.kubebuilder.io/v3
3 participants