Skip to content
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

Merged
merged 3 commits into from
Dec 2, 2024

Conversation

manusa
Copy link
Contributor

@manusa manusa commented Oct 4, 2024

What this PR does / why we need it:

@metal3-io-bot metal3-io-bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 4, 2024
@metal3-io-bot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@metal3-io-bot metal3-io-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 4, 2024
manusa added 2 commits October 4, 2024 16:20
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>
@tuminoid
Copy link
Member

tuminoid commented Oct 7, 2024

/ok-to-test

@metal3-io-bot metal3-io-bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 7, 2024
@tuminoid
Copy link
Member

tuminoid commented Oct 7, 2024

/cc @kashifest @zaneb @elfosardo

@kashifest
Copy link
Member

/approve
I am ok with this change, but I would like @zaneb to have a look also .
/hold

@metal3-io-bot metal3-io-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 8, 2024
@metal3-io-bot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@metal3-io-bot metal3-io-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 8, 2024
Copy link
Member

@zaneb zaneb left a 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
Copy link
Member

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?

Copy link
Contributor Author

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:

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).

Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// +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 ?

Copy link
Contributor Author

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.

Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was already added

Copy link
Member

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 🤦

Co-authored-by: Kashif Khan <kashif.khan@est.tech>
Signed-off-by: Marc Nuri <marc@marcnuri.com>
@kashifest
Copy link
Member

@lentzi90 do you have any opinion on this? otherwise we can unhold

Copy link
Member

@lentzi90 lentzi90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/hold cancel

@metal3-io-bot metal3-io-bot added lgtm Indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Dec 2, 2024
@metal3-io-bot metal3-io-bot merged commit 227b7ff into metal3-io:main Dec 2, 2024
17 checks passed
@manusa manusa deleted the fix/comment-tags branch December 2, 2024 11:31
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants