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

generate openapi removes shortNames from CRD #1323

Closed
enisoc opened this issue Apr 12, 2019 · 1 comment · Fixed by #1278
Closed

generate openapi removes shortNames from CRD #1323

enisoc opened this issue Apr 12, 2019 · 1 comment · Fixed by #1278
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@enisoc
Copy link

enisoc commented Apr 12, 2019

Bug Report

What did you do?

  1. operator-sdk add api ...
  2. Edit deploy/crds/my_crd.yaml to add shortNames: ["blah"].
  3. operator-sdk generate openapi

What did you expect to see?
The validation section should be filled in without removing my shortNames.

What did you see instead? Under which circumstances?
The generator removed my shortNames.

Environment

  • operator-sdk version: v0.7.0
  • go version: 1.12.2

Additional context

I also tried the +kubebuilder annotation for setting shortNames, but it was ignored:

// +kubebuilder:resource:path=services,shortName=to;ty
@hasbro17
Copy link
Contributor

Thanks for reporting this.

This is another bug because of the way we currently try to regenerate only the validation block and preserve everything else in the existing CRD manifest.
Except it turns out we're also stomping out the spec.names section.
https://github.com/operator-framework/operator-sdk/blob/master/internal/pkg/scaffold/crd.go#L138-L139

This was due to an older assumption where the controller-tools CRD generator didn't support generating Singular names. But that's been fixed now with the +kubebuilder:singular tag.
https://github.com/kubernetes-sigs/controller-tools/blob/master/pkg/internal/codegen/parse/crd.go#L89-L92
kubernetes-sigs/controller-tools#142

We're planning to fix this in #1278 by regenerating the entire CRD on operator-sdk generate openapi so that we entirely rely on the +kubebuilder:... tags and not try to preserve manual edits.

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