ahmetb / gen-crd-api-reference-docs

API Reference Docs generator for Kubernetes CRDs (used by Knative, Kubeflow and others)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[wip] Add support for kubebuilder v2

xrmzju opened this issue · comments

[wip] Add support for kubebuilder v2

for now, two things should do:

  • v2 does not generate doc.go, groupName should not take from doc.go
  • // +genclient comment not supported in v2, should not use this to judge a export type

I encourage you to take a look at the source code.

We heavily rely on //+ comments for discovering certain things like apiGroups, optional fields etc.

If there's an alternative way we can discover these things, we can make code changes. The code is pretty straightforward, search for ExtractCommentTags ,//+ , // + etc.

Maybe there's an easy fix.

The code for extracting group name is this line:
https://github.com/ahmetb/gen-crd-api-reference-docs/blob/master/main.go#L190

The package comments are considered by gengo only if it appears in doc.go,
https://github.com/kubernetes/gengo/blob/master/types/types.go#L120
which seems unnecessarily restrictive. kubebuilder v2 no longer generates doc.go.

Is it possible to consider type comments instead of package comments? For kubebuilder v2, some type comments contains // +groupName=...

(A temporary workaround is to manually create a doc.go which contains the // +groupName=... comment.)

Is it possible to consider type comments instead of package comments? For kubebuilder v2, some type comments contains // +groupName=...

Let's be more crisp here. Does every single type that correspond to a CRD actually have this field? (We currently inherit groupName for all types from that.) We currently have 1:1 mapping between "Go packages : groupName".

Let's first make sure these two assumptions still hold true.

Is it possible to consider type comments instead of package comments? For kubebuilder v2, some type comments contains // +groupName=...

Let's be more crisp here. Does every single type that correspond to a CRD actually have this field? (We currently inherit groupName for all types from that.) We currently have 1:1 mapping between "Go packages : groupName".

Let's first make sure these two assumptions still hold true.

To correct my observation: the groupName comments appear in groupversion_info.go at package level.

Examples:
https://github.com/kubeflow/kubeflow/blob/master/components/notebook-controller/api/v1/groupversion_info.go

https://github.com/kubeflow/kubeflow/blob/master/components/profile-controller/api/v1/groupversion_info.go

@ahmetb Any update on kube builder support ?

Nope, I am not actively working on this.

@ahmetb I think some one create a pr for the issue. #26

This does currently not work for operators made with later versions of kubebuilder.