Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
internal/generate: align CRD generator with controller-gen #2201
internal/generate: align CRD generator with controller-gen #2201
Changes from 4 commits
ee02715
510d5ba
0cf9bd9
8827ac5
adb541b
10cc359
7dcdff3
6cf5f5f
2875c25
658249a
0e10559
6a311cc
af7b9b1
8618098
53b0ee8
4048006
730e77b
8b6c940
2bf52f0
9e0a18c
6820652
d7db46e
188e591
e2a903d
034f7f2
d74399d
d3ed3c8
b1e73a4
83e7099
8e6532b
9d5b9bd
200b572
d4fed40
04204d1
f4a61a5
f227322
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that without manually adding
+kubebuilder:storageversion
in advance,operator-sdk add api
errors out when another version is added to an existing CRD with the same group & kind.This problem may be out-of-scope for this PR, but something we may want to think about whether there's a more graceful way to handle from a user experience perspective.
Here's the error I get:
It's a good hint, but could be improved by telling the user how to fix the problem. Can we put this note into the error message, nearly verbatim and skip outputting the usage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I just noticed that it's possible to define
+kubebuilder:storageversion
in both versions of a CRD's types.go files and controller-gen happily creates a CRD wherestorage: true
exists in both versions. That should also be an error right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 on not printing usage. By note do you mean:
Two CRD versions with
storage: true
is an error, but controller-tools does not consider this an error during generation. I will submit an issue if one does not exist already upstream.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I meant based on the note that you have in the user guide:
Something like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generator errors are not returned by
Runtime.Run()
so we can't check if the error returned pertains to no+kubebuilder:storageversion
annotation. How about linking https://book.kubebuilder.io/reference/generating-crd.html in an error message forRuntime.Run()
errors? This should cover this and other errors, but isn't as specific.