-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
🌱 Add missing comment tags #1985
Conversation
Hi @manusa. Thanks for your PR. I'm waiting for a metal3-io member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Signed-off-by: Marc Nuri <marc@marcnuri.com>
Most go code generators such as kube-openapi rely on gengo [1] to infer the annotated tags. When dealing with package annotations, gengo extracts them from the doc.go file [2]. The types defined in apis/metal3.io/v1alpha1 do have a package annotated with +groupName. However, the annotation is in the groupversion_info.go file instead. You can see comments that refer to this issue [3] [4] [1] https://github.com/kubernetes/gengo/ [2] https://github.com/kubernetes/gengo/blob/2b36238f13e9b8aebe4c286c2ffb2fc71f4be3c5/types/types.go#L121-L126 [3] kubernetes/code-generator#150 (comment) [4] kubernetes/code-generator#135 Signed-off-by: Marc Nuri <marc@marcnuri.com>
1fe0553
to
6b123cc
Compare
/ok-to-test |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kashifest The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
TBH I have no idea what any of this does.
|
||
// Package v1alpha1 contains API Schema definitions for the metal3.io v1alpha1 API group | ||
// +kubebuilder:object:generate=true | ||
// +groupName=metal3.io |
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.
These comments already exist here. Do we need 2 or should we delete those ones?
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 left them there because I'm unsure if someone might be relying on those.
IMO they should be just in doc.go
, but it might be better to defer the removal or leave them there after all.
I tried to find an example of a similar situation in a different project from the metal3-io org.
You can find something similar going on in the cluster-api-provider project.
The v1alpha5
types contain both doc.go
and groupversion_info.go
files with the duplicate comment tags.
The same happens for the more recent v1beta1
:
- https://github.com/metal3-io/cluster-api-provider-metal3/blob/5dceef85d4794a647161e2bfac57b66554e573b2/api/v1beta1/doc.go#L22
- https://github.com/metal3-io/cluster-api-provider-metal3/blob/5dceef85d4794a647161e2bfac57b66554e573b2/api/v1beta1/groupversion_info.go#L22
TBH I have no idea what any of this does.
The comment tags are mainly used for code and spec generation.
Hence the breaking changes in the generated code, which is now actually considering the tag that was previously ignored since it was only in the groupversion_info.go
file.
In my case I'm using them to generate an OpenAPI spec with kube-openapi and with that spec generate reliable Java types 🤯 (fabric8io/kubernetes-client#6417).
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.
Looks fine to keep both.
*/ | ||
|
||
// Package v1alpha1 contains API Schema definitions for the metal3.io v1alpha1 API group | ||
// +kubebuilder:object:generate=true |
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.
// +kubebuilder:object:generate=true | |
// +k8s:openapi-gen=true |
Shouldn't this be k8s:openapi-gen=true
then instead if this is meant for kube-openapi ?
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.
Yes, definitely. In my case I don't need those because I'm using a customized filter function for kube-openapi.
But for the standard usecase it's most definitely required.
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.
Please add
// +k8s:openapi-gen=true
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.
It was already added
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, sorry! I missed it since it was below the comment 🤦
a324e47
to
f78a656
Compare
Co-authored-by: Kashif Khan <kashif.khan@est.tech> Signed-off-by: Marc Nuri <marc@marcnuri.com>
f78a656
to
741dffc
Compare
@lentzi90 do you have any opinion on this? otherwise we can unhold |
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.
/lgtm
/hold cancel
What this PR does / why we need it:
fix: add json tags to match field annotation tag
+patchStrategy
fix: add missing doc.go for proper groupName inference
Most go code generators such as kube-openapi rely on gengo [1] to infer the annotated tags.
When dealing with package annotations, gengo extracts them from the doc.go file [2].
The types defined in
apis/metal3.io/v1alpha1
do have a package annotated with+groupName
.However, the annotation is in the
groupversion_info.go
file instead.You can see comments that refer to this issue [3] [4]
[1] https://github.com/kubernetes/gengo/
[2] https://github.com/kubernetes/gengo/blob/2b36238f13e9b8aebe4c286c2ffb2fc71f4be3c5/types/types.go#L121-L126
[3] applyconfiguration-gen does not respect the +groupName tag and uses the plain apiVersion kubernetes/code-generator#150 (comment)
[4]
groupName
defined intypes.go
is not used for fake clients kubernetes/code-generator#135