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

Type aliases resolve too aggressively in the generated API documentation #210

Closed
jpeach opened this issue Jun 10, 2020 · 9 comments
Closed
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.
Milestone

Comments

@jpeach
Copy link
Contributor

jpeach commented Jun 10, 2020

What happened:

All the type aliases for ConfigMapsDefaultLocalObjectReference end up linking back to a single documentation block. We lose the unique documentation present at each alias declaration.

Fields that are an instance of the type alias are also collapsed into the underlying type, which is not what we want.

Screen Shot 2020-06-10 at 3 42 39 pm

What you expected to happen:

Each type alias should get its own documentation block, ie. for each of these:

api/v1alpha1/gateway_types.go:type ListenerExtensionObjectReference = ConfigMapsDefaultLocalObjectReference
api/v1alpha1/gatewayclass_types.go:type GatewayClassParametersObjectReference = ConfigMapsDefaultLocalObjectReference
api/v1alpha1/httproute_types.go:type RouteMatchExtensionObjectReference = ConfigMapsDefaultLocalObjectReference
api/v1alpha1/httproute_types.go:type RouteFilterExtensionObjectReference = ConfigMapsDefaultLocalObjectReference
api/v1alpha1/httproute_types.go:type RouteActionExtensionObjectReference = ConfigMapsDefaultLocalObjectReference
api/v1alpha1/httproute_types.go:type RouteHostExtensionObjectReference = ConfigMapsDefaultLocalObjectReference
@jpeach jpeach added the kind/bug Categorizes issue or PR as related to a bug. label Jun 10, 2020
@bowei
Copy link
Contributor

bowei commented Jun 10, 2020

This looks to be a consequence of how type aliases behave in Golang. They don't show up as actual types.
Maybe it's better to just reuse the same type instead of alias for the time being?

@jpeach
Copy link
Contributor Author

jpeach commented Jun 10, 2020

@jpeach
Copy link
Contributor Author

jpeach commented Jun 10, 2020

This looks to be a consequence of how type aliases behave in Golang. They don't show up as actual types.

The generator is using gengo, so I think that it can distinguish type aliases in the source.

Maybe it's better to just reuse the same type instead of alias for the time being?

One thing I was playing with is inlining the type rather than aliasing. This probably gets the same result in YAML, JSON and Go, but not in protobuf.

diff --git api/v1alpha1/httproute_types.go api/v1alpha1/httproute_types.go
index e290acc..ba22865 100644
--- api/v1alpha1/httproute_types.go
+++ api/v1alpha1/httproute_types.go
@@ -273,7 +273,9 @@ type TargetPort int32
 // route action within a known namespace.
 //
 // +k8s:deepcopy-gen=false
-type ForwardToTargetObjectReference = ServicesDefaultLocalObjectReference
+type ForwardToTargetObjectReference struct {
+       ServicesDefaultLocalObjectReference `json:",inline" protobuf:"bytes,1,opt,name=servicesDefaultLocalObjectReference"`
+}

 // RouteActionExtensionObjectReference identifies a route-action extension
 // object within a known namespace.

@jpeach
Copy link
Contributor Author

jpeach commented Jun 10, 2020

I filed kubernetes/gengo#180 for gengo. I agree that we should probably look for a local workaround.

@jpeach jpeach changed the title Type aliases resolve to aggressively in the generated API documentation Type aliases resolve to0 aggressively in the generated API documentation Jun 16, 2020
@jpeach jpeach changed the title Type aliases resolve to0 aggressively in the generated API documentation Type aliases resolve too aggressively in the generated API documentation Jun 16, 2020
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/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 Sep 14, 2020
@robscott
Copy link
Member

may be fixed by changing
type ForwardToTargetObjectReference = ServicesDefaultLocalObjectReference
to
type ForwardToTargetObjectReference ServicesDefaultLocalObjectReference

@robscott robscott added this to the v1alpha1 milestone Sep 24, 2020
@robscott
Copy link
Member

robscott commented Oct 8, 2020

/assign @bowei

@hbagdi
Copy link
Contributor

hbagdi commented Oct 13, 2020

#378
/close

@k8s-ci-robot
Copy link
Contributor

@hbagdi: Closing this issue.

In response to this:

#378
/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.

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/stale Denotes an issue or PR has remained open with no activity and has become stale.
Projects
None yet
Development

No branches or pull requests

6 participants