Skip to content
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

🐛 (go/v4): Scaffold when no boilerplate file #3378

Merged
merged 2 commits into from
May 2, 2023

Conversation

yyy1000
Copy link
Member

@yyy1000 yyy1000 commented May 1, 2023

Description

This pull request addresses issue #3373, which prevented kubebuilder from creating an API when no boilerplate file was present.
I have tested the changes locally with the following steps:

  1. Rebuilt the Kubebuilder binary with updated code
  2. Used Kubebuilder to initialize a new project
  3. Deleted the 'boilerplate' file
  4. Modified the 'generate' target in the Makefile as follows:
.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
	$(CONTROLLER_GEN) object paths="./..."
  1. Executed the 'create api' command.

Additionally, I tried to make some changes that enable the 'create api' command to modify the 'Makefile' when there's no boilerplate file and let the user skip step 4 altogether, making it possible to successfully run 'post-scaffold'(make generate). It seems not a little change, but I'm glad to do that if it is worth doing. :)

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented May 1, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: yyy1000 / name: Junhao Liu (8d67388)

@k8s-ci-robot
Copy link
Contributor

Welcome @yyy1000!

It looks like this is your first PR to kubernetes-sigs/kubebuilder 🎉. 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 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. 😃

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 1, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @yyy1000. 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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels May 1, 2023
@@ -67,7 +67,7 @@ func (s *apiScaffolder) Scaffold() error {
// Load the boilerplate
boilerplate, err := afero.ReadFile(s.fs.FS, hack.DefaultBoilerplatePath)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

could we specifyically check for fileNotFound error and skip with errors.Is(err, afero.ErrFileNotFound). In case its something else (like permission issue), we can return the error.

Copy link
Member

@camilamacedo86 camilamacedo86 May 1, 2023

Choose a reason for hiding this comment

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

+1 in in the above suggestion.

We need only to use an empty string when we know the file does not exist.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you! It's very helpful. 😀 I made changes on this.

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.

/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 May 1, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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 May 1, 2023
@camilamacedo86
Copy link
Member

//test pull-kubebuilder-e2e-k8s-1-24-7

@camilamacedo86
Copy link
Member

Also,

/lgtm

Since address the Varsha suggestions either.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 1, 2023
@camilamacedo86
Copy link
Member

/pull-kubebuilder-e2e-k8s-1-24-7

@camilamacedo86
Copy link
Member

/test pull-kubebuilder-e2e-k8s-1-24-7

@yyy1000
Copy link
Member Author

yyy1000 commented May 2, 2023

/retest

1 similar comment
@yyy1000
Copy link
Member Author

yyy1000 commented May 2, 2023

/retest

@k8s-ci-robot k8s-ci-robot merged commit 9af6ca4 into kubernetes-sigs:master May 2, 2023
@yyy1000 yyy1000 deleted the dev branch May 2, 2023 05:24
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/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants