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

Accept empty group name and domain #1975

Closed
Adirio opened this issue Jan 27, 2021 · 5 comments
Closed

Accept empty group name and domain #1975

Adirio opened this issue Jan 27, 2021 · 5 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@Adirio
Copy link
Contributor

Adirio commented Jan 27, 2021

The "core" builtin api group contains Resources such as Pod or Namespace (full list).

This group's uses both an empty group and an empty domain.

Currently, while one of domain or group ar allowed to be empty, both are not allowed to be empty.

/kind bug

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

In my POV the error/bug is NOT regarding not allow be both empty, but its logic. And might I would consider it an RFE to support core types. See:

By running kubebuilder create api --group core --version v1 --kind Pod --resource=false --controller=true;

$ kubebuilder create api --group core --version v1 --kind Pod --force
Create Resource [y/n]
n
Create Controller [y/n]
y
Writing scaffold for you to edit...
controllers/pod_controller.go
Running make:
$ make generate
go: creating new go.mod: module tmp
Downloading sigs.k8s.io/controller-tools/cmd/[email protected]
go: found sigs.k8s.io/controller-tools/cmd/controller-gen in sigs.k8s.io/controller-tools v0.4.1
/Users/camilamacedo/go/src/example/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."

I'd expected that the controller was created using/importing the Pod core type and that the PROJECT file would store an empty string for the domain. However, if I asked to generate the resource in the project then, it would no longer be related to the core type besides the name and the resource.domain should equal the project domain.

So, the above scenario results now in:

 $ cat PROJECT 
domain: my.domain
layout: go.kubebuilder.io/v3
projectName: example
repo: example
version: "3"

When should be

domain: my.domain
layout: go.kubebuilder.io/v3
projectName: example
repo: example
resources:
- controller: true
  group: core
  kind: Pod
  path: k8s.io/core/apps/v1
  version: v1
version: "3"

Also, its controller is missing the import for the core api.

Is it make sense?

@Adirio
Copy link
Contributor Author

Adirio commented Feb 9, 2021

I don't consider this a bug (probably i used the bug template)
/remove-kind bug
/kind feature

There is definetely a need to fully support core types, but this is not talking about that. This is a pre-requisite for that.
One of the many core groups is the so called "core" api group. The problem is that this group has an empty Group and Domain, both, and currently the Resource validation only allows one of them to be empty not both. It's not as simple as removing that check because there are some places in the scaffolded files, like the import alias or fully qualified group name where it expects at least one to be non-empty and would result in errors at scaffolding.

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. and removed kind/bug Categorizes issue or PR as related to a bug. labels Feb 9, 2021
@camilamacedo86
Copy link
Member

As we spoke in the kb meeting, we agreed in close this one but we will raise a new one just to discuss and see how we can address the problem "how to support external types".

@camilamacedo86
Copy link
Member

c/c @estroz

@estroz
Copy link
Contributor

estroz commented Feb 9, 2021

See #1999

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

No branches or pull requests

4 participants