Skip to content

Commit

Permalink
Merge pull request #276 from pmorie/categories-controller-install
Browse files Browse the repository at this point in the history
Add categories to the CRD installed by the controller
  • Loading branch information
k8s-ci-robot committed Jun 21, 2018
2 parents 2ca8b7a + ee77a60 commit a523fb6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/internal/codegen/parse/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ func (b *APIs) parseCRDs() {

if HasCategories(resource.Type) {
categoriesTag := getCategoriesTag(resource.Type)
resource.CRD.Spec.Names.Categories = strings.Split(categoriesTag, ",")
categories := strings.Split(categoriesTag, ",")
resource.CRD.Spec.Names.Categories = categories
resource.Categories = categories
}

if HasStatusSubresource(resource.Type) {
Expand Down
2 changes: 2 additions & 0 deletions cmd/internal/codegen/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ type APIResource struct {
DocAnnotation map[string]string
// HasStatusSubresource indicates that the resource has a status subresource
HasStatusSubresource bool
// Categories is a list of categories the resource is part of.
Categories []string
}

type APISubresource struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ var (
{{ if .ShortName -}}
ShortNames: []string{"{{.ShortName}}"},
{{ end -}}
{{ if .Categories -}}
Categories: []string{
{{ range .Categories -}}
"{{ . }}",
{{ end -}}
},
{{ end -}}
},
{{ if .NonNamespaced -}}
Scope: "Cluster",
Expand Down
1 change: 1 addition & 0 deletions cmd/kubebuilder/create/resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type resourceTemplateArgs struct {
PluralizedKind string
NonNamespacedKind bool
HasStatusSubresource bool
Categories []string
}

func doResource(dir string, args resourceTemplateArgs) bool {
Expand Down
1 change: 1 addition & 0 deletions cmd/kubebuilder/create/resource/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func createResource(boilerplate string) {
inflect.NewDefaultRuleset().Pluralize(createutil.KindName),
nonNamespacedKind,
false,
nil,
}

dir, err := os.Getwd()
Expand Down

0 comments on commit a523fb6

Please sign in to comment.