File tree 5 files changed +14
-1
lines changed
kubebuilder/create/resource
kubebuilder-gen/internal/resourcegen
5 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,9 @@ func (b *APIs) parseCRDs() {
77
77
78
78
if HasCategories (resource .Type ) {
79
79
categoriesTag := getCategoriesTag (resource .Type )
80
- resource .CRD .Spec .Names .Categories = strings .Split (categoriesTag , "," )
80
+ categories := strings .Split (categoriesTag , "," )
81
+ resource .CRD .Spec .Names .Categories = categories
82
+ resource .Categories = categories
81
83
}
82
84
83
85
if HasStatusSubresource (resource .Type ) {
Original file line number Diff line number Diff line change @@ -166,6 +166,8 @@ type APIResource struct {
166
166
DocAnnotation map [string ]string
167
167
// HasStatusSubresource indicates that the resource has a status subresource
168
168
HasStatusSubresource bool
169
+ // Categories is a list of categories the resource is part of.
170
+ Categories []string
169
171
}
170
172
171
173
type APISubresource struct {
Original file line number Diff line number Diff line change @@ -127,6 +127,13 @@ var (
127
127
{{ if .ShortName -}}
128
128
ShortNames: []string{"{{.ShortName}}"},
129
129
{{ end -}}
130
+ {{ if .Categories -}}
131
+ Categories: []string{
132
+ {{ range .Categories -}}
133
+ "{{ . }}",
134
+ {{ end -}}
135
+ },
136
+ {{ end -}}
130
137
},
131
138
{{ if .NonNamespaced -}}
132
139
Scope: "Cluster",
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ type resourceTemplateArgs struct {
36
36
PluralizedKind string
37
37
NonNamespacedKind bool
38
38
HasStatusSubresource bool
39
+ Categories []string
39
40
}
40
41
41
42
func doResource (dir string , args resourceTemplateArgs ) bool {
Original file line number Diff line number Diff line change @@ -110,6 +110,7 @@ func createResource(boilerplate string) {
110
110
inflect .NewDefaultRuleset ().Pluralize (createutil .KindName ),
111
111
nonNamespacedKind ,
112
112
false ,
113
+ nil ,
113
114
}
114
115
115
116
dir , err := os .Getwd ()
You can’t perform that action at this time.
0 commit comments