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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Use correct file name in the comments of [kind]_types.go #1927

Conversation

south37
Copy link
Contributor

@south37 south37 commented Dec 30, 2020

WHY (= Motivation)

What broke (please include exact error messages if you can)

When we use $ kubebuilder create api, it generates a file like [kind]_types.go. In this file, there is a comment that indicates which file to change when adding a field.

However, the file name in the comment is different from the generated file name. This difference can confuse people.

The example is shown below.

$ kubebuilder create api --group webapp --version v1 --kind Guestbook
Create Resource [y/n]
y
Create Controller [y/n]
y
Writing scaffold for you to edit...
api/v1/guestbook_types.go
controllers/guestbook_controller.go
Running make:
$ make
$PATH/.go/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
go fmt ./...
go vet ./...
go build -o bin/manager main.go
kubebuilder create api --group webapp --version v1 --kind Guestbook  6.82s user 5.43s system 153% cpu 7.959 total
$ cat api/v1/guestbook_types.go | grep 'Edit Guestbook_types\.go'
        // Foo is an example field of Guestbook. Edit Guestbook_types.go to remove/update

In the above example, Guestbook_types.go is written in a comment. This is different from the correct file name guestbook_types.go.

What did you expect to happen? What do you think went wrong?

A comment should use a correct file name. In the above example, guestbook_types.go should be used.

cf. The correct file name should be used in the comments of [kind]_types.go #1925

WHAT (= A description of the change)

Fixed the comments in [kind]_types.go. The file names in the comments are now correct.

To be more specific, I updated the following files.

Then executed $ make generate. This execution updated the mock data used in the e2e test.

Fixes #1925

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

Welcome @south37!

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
Copy link
Contributor

Hi @south37. 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 30, 2020
Copy link
Contributor

@Adirio Adirio left a comment

Choose a reason for hiding this comment

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

Templates already have access to the lower function, don't need to mess with mixins for this. Revert the changes in pkg/model/file/mixins.go and apply the changes below. The resulting testdata folder should be the same as in this PR.

@Adirio
Copy link
Contributor

Adirio commented Jan 4, 2021

/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 Jan 4, 2021
@south37
Copy link
Contributor Author

south37 commented Jan 4, 2021

@Adirio
Thanks for your kind comments! 馃槃
I reverted the previous commit ( aaba479 ) and applied the suggested changes! 馃挕

@south37
Copy link
Contributor Author

south37 commented Jan 4, 2021

CI / Verify testdata directory (pull_request) seems to have failed due to the fact that it is now 2021 馃檲
Should I add a commit to fix this? Or should I wait until the master is fixed?

.
.
.
git diff testdata
diff --git a/testdata/project-v2-addon/api/v1/admiral_types.go b/testdata/project-v2-addon/api/v1/admiral_types.go
index b2a0b75..843fbe3 100644
--- a/testdata/project-v2-addon/api/v1/admiral_types.go
+++ b/testdata/project-v2-addon/api/v1/admiral_types.go
@@ -1,5 +1,5 @@
 /*
-Copyright 2020 The Kubernetes authors.
+Copyright 2021 The Kubernetes authors.
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
.
.
.

cf. https://github.com/kubernetes-sigs/kubebuilder/runs/1643192980#step:5:1224

Copy link
Contributor

@prafull01 prafull01 left a comment

Choose a reason for hiding this comment

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

@south37 Thanks for your contribution. I have raised a #1929 for fixing the year in testdata. You need to rebase this branch with master once that PR gets merged.

Also, can you please squash all your commits into 1 commit..

@south37 south37 force-pushed the use-lowered-resource-kind-as-file-name branch from d7c30ff to ea0edf3 Compare January 5, 2021 06:13
@south37
Copy link
Contributor Author

south37 commented Jan 5, 2021

@prafull01
Thanks for your kind comment! 馃挕 OK, I'll wait for that PR to be merged.
I also squashed all my commits into 1 commit!

Copy link
Contributor

@Adirio Adirio left a comment

Choose a reason for hiding this comment

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

/lgtm

/hold
Holding until the 2021 copyright gets fixed

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 5, 2021
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 5, 2021
@south37 south37 force-pushed the use-lowered-resource-kind-as-file-name branch from ea0edf3 to aa9c2e0 Compare January 6, 2021 04:56
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 6, 2021
@south37
Copy link
Contributor Author

south37 commented Jan 6, 2021

#1929 was merged to master branch, so I rebased this branch! 馃挕

@prafull01
Copy link
Contributor

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 6, 2021
@south37
Copy link
Contributor Author

south37 commented Jan 6, 2021

You can assign the PR to them by writing /assign @pwittrock in a comment when ready.

OK.
/assign @pwittrock

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.

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Adirio, camilamacedo86, prafull01, south37

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 Jan 6, 2021
@camilamacedo86
Copy link
Member

The 2020/2021 is fixed already it shows fine to get merged. So
/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 6, 2021
@k8s-ci-robot k8s-ci-robot merged commit f660017 into kubernetes-sigs:master Jan 6, 2021
@south37 south37 deleted the use-lowered-resource-kind-as-file-name branch January 7, 2021 02:47
@south37
Copy link
Contributor Author

south37 commented Jan 7, 2021

Thank you for your kind review! 馃槃

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.

The correct file name should be used in the comments of [kind]_types.go
6 participants