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

unable to generate controller for the core group #1191

Closed
raffaelespazzoli opened this issue Mar 9, 2019 · 2 comments · Fixed by #1313
Closed

unable to generate controller for the core group #1191

raffaelespazzoli opened this issue Mar 9, 2019 · 2 comments · Fixed by #1313
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@raffaelespazzoli
Copy link
Contributor

raffaelespazzoli commented Mar 9, 2019

Bug Report

What did you do?
A clear and concise description of the steps you took (or insert a code snippet).
here is the command I issued and corresponding error:

operator-sdk add controller --api-version=core/v1 --kind=Namespace
INFO[0000] Generating controller version core/v1 for kind Namespace. 
Error: group cannot be empty
Usage:
  operator-sdk add controller [flags]

Flags:
      --api-version string   Kubernetes APIVersion that has a format of $GROUP_NAME/$VERSION (e.g app.example.com/v1alpha1)
  -h, --help                 help for controller
      --kind string          Kubernetes resource Kind name. (e.g AppService)

What did you expect to see?
A clear and concise description of what you expected to happen (or insert a code snippet).
controller correclty generated

What did you see instead? Under which circumstances?
A clear and concise description of what you expected to happen (or insert a code snippet).
see error above

Environment

  • operator-sdk version:
operator-sdk --version
operator-sdk version v0.5.0+git

notice that this version is misleading. I am actually using the binary resulting from the compilation of the master branch.

Possible Solution

this worked:

operator-sdk add controller --api-version=core.com/v1 --kind=Namespace
INFO[0000] Generating controller version core.com/v1 for kind Namespace. 
INFO[0000] Created pkg/controller/namespace/namespace_controller.go 
INFO[0000] Created pkg/controller/add_namespace.go      
INFO[0000] Controller generation complete. 

I can fix the generated code manually.

Additional context
Add any other context about the problem here.

@hasbro17
Copy link
Contributor

@raffaelespazzoli Thanks for reporting the issue.

We have the check for group names to prevent users from adding single group names for their CRDs.
From the kubernetes API conventions guidelines:

Group names are typically in domain name form - the Kubernetes project reserves use of the empty group, all single word names ("extensions", "apps"), and any group name ending in "*.k8s.io" for its sole use. When choosing a group name, we recommend selecting a subdomain your group or organization owns, such as "widget.mycompany.com".

But I guess that only makes sense for defining new apis. If you're adding a controller to watch a k8s resource(with a single word group) as the primary resource then that'll be a problem.

As a work around for now, you can fix it in after the fact. add controller --api-version=core.com/v1 and then change the group to core the file.

@estroz Since that was added in #815 I was wondering if we can somehow relax this check for when we add controllers, or altogether with a warning?

Side note: Truncated the issue for clarity and removing the prompt for Gopkg.lock in the bug report template #1194

@hasbro17 hasbro17 added the kind/bug Categorizes issue or PR as related to a bug. label Mar 11, 2019
@hasbro17
Copy link
Contributor

@estroz Just pinging again to get your input before I make the fix which should be a small one.

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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants