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

groupName defined in types.go is not used for fake clients #135

Closed
kleimkuhler opened this issue Oct 28, 2021 · 10 comments
Closed

groupName defined in types.go is not used for fake clients #135

kleimkuhler opened this issue Oct 28, 2021 · 10 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@kleimkuhler
Copy link

kleimkuhler commented Oct 28, 2021

When defining multiple APIs with the same version (say v1), the +groupName tag needs to be in types.go instead of doc.go in order to not overwrite generated types in clientset.go.

However, the group name defined by +groupName in types.go is not used for the fake_xxx.go files.

This results in trying to use test clients that have the incorrect group name and needs to be manually edited.

Reproduction

I attempted a minimal-ish reproduction with this go-generator-test.

In this test, example and example2 both use the v1 version. When update-codegen.shis run, the code generated is mostly correct:

  • The correct SchemeGroupVersion is generated (it's using the foo.bar group name)
  • clientset.go generates the correct package names for both examples

However, if you look at the fake_xxx.go files, the group version is incorrect. It is example or example2 when it should be foo.bar.

Now, if +groupName is moved from types.go to doc.go for each of the APIs, then this issue is fixed, but duplicate package names are generated as show here.

What the fix should do

I would expect the +groupName defined in types.go to be used in the generated fake_xxx.go files so that the correct group name is used.

@kleimkuhler
Copy link
Author

/kind bug

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Oct 28, 2021
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 26, 2022
@olix0r
Copy link

olix0r commented Jan 26, 2022

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 26, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 26, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels May 26, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

@k8s-ci-robot
Copy link

@k8s-triage-robot: Closing this issue.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

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/test-infra repository.

@swathinsankaran
Copy link

/reopen

@k8s-ci-robot
Copy link

@swathinsankaran: You can't reopen an issue/PR unless you authored it or you are a collaborator.

In response to this:

/reopen

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/test-infra repository.

@manusa
Copy link

manusa commented Oct 4, 2024

FWIW the +groupName tag should be in a doc.go file which is the one that gengo uses to parse the comments.

https://github.com/kubernetes/gengo/blob/2b36238f13e9b8aebe4c286c2ffb2fc71f4be3c5/types/types.go#L121-L126

manusa added a commit to marcnuri-forks/baremetal-operator that referenced this issue Oct 4, 2024
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
manusa added a commit to marcnuri-forks/baremetal-operator that referenced this issue Oct 4, 2024
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>
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. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

6 participants