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

Add the controller-gen markers in types.go if the --plural is specified #1805

Closed
prafull01 opened this issue Nov 9, 2020 · 5 comments · Fixed by #1967
Closed

Add the controller-gen markers in types.go if the --plural is specified #1805

prafull01 opened this issue Nov 9, 2020 · 5 comments · Fixed by #1967
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@prafull01
Copy link
Contributor

prafull01 commented Nov 9, 2020

This is a follow up of the following PR: #1802

Controller-gen markers for apis should be added if the specific plural is provided by the user. Lets consider the following scenario:

prafull@EMPID18004:~/go/src/github.com/prafull01/kubebuilder/proj$ ../bin/kubebuilder create api --group=praf --kind=Fernandez --version=v1 --plural=Fernandezes
Create Resource [y/n]
y
Create Controller [y/n]
y
Writing scaffold for you to edit...
api/v1/fernandez_types.go
controllers/fernandez_controller.go
Running make:
$ make
/home/prafull/go/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
go fmt ./...
go vet ./...
go build -o bin/manager main.go

PROJECT file:

prafull@EMPID18004:~/go/src/github.com/prafull01/kubebuilder/proj$ cat PROJECT 
domain: my.domain
layout: go.kubebuilder.io/v3-alpha
projectName: proj
repo: sigs.k8s.io/kubebuilder/v2
resources:
- group: praf
  kind: Fernandez
  plural: Fernandezes
  version: v1
version: 3-alpha

CRD file:

group: praf.my.domain
  names:
    kind: Fernandez
    listKind: FernandezList
    plural: fernandezs
    singular: fernandez
  scope: Namespaced

It should add marker (here) in the api/_types.go file which will actually add the plurals in the CRD as well.

/kind bug

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Nov 9, 2020
@camilamacedo86
Copy link
Member

Hi @Adirio and @prafull01,

Could not it be addressed in the #1802 as well?

@Adirio
Copy link
Contributor

Adirio commented Nov 9, 2020

I think that this is more a bug that should be addressed while the other is an added feature

@camilamacedo86
Copy link
Member

camilamacedo86 commented Nov 17, 2020

Hi @prafull01,

See the comment #1802 (review), shows that we have a bug related to pluralize. I am not sure if we should add this option --plural=Fernandezes at all. Shows that what is required is to fix the scenarios where it has not been done as expected.

@prafull01
Copy link
Contributor Author

Hi @camilamacedo86

This option is already present in the webhook api creation of the kubebuilder, however the name of this option is --resource there.

For example, this command generates the following markers (please check the Plurals Frigatees):

../bin/kubebuilder create webhook --version v1beta1 --group ship --kind Frigate  --defaulting --programmatic-validation --resource Frigatees
Writing scaffold for you to edit...
api/v1beta1/frigate_webhook.go

// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
// +kubebuilder:webhook:verbs=create;update,path=/validate-ship-example-com-v1beta1-frigate,mutating=false,failurePolicy=fail,groups=ship.example.com,resources=Frigatees,versions=v1beta1,name=vfrigate.kb.io

IMHO If we are providing this option for webhook, then we should provide same option for api creation as well or not provide at all for both.

@Adirio
Copy link
Contributor

Adirio commented Nov 17, 2020

IMHO, markers should be added if required to fix Plural as it is not currently working. We didn't notice because it is not available to cli users to modify, and therefore, we don't have tests for this. Adding the flag is a separate topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants