Skip to content

Commit

Permalink
Merge pull request #220 from ironcladlou/crd-scope
Browse files Browse the repository at this point in the history
✨ crd: add a resource scope marker
  • Loading branch information
k8s-ci-robot committed Jun 6, 2019
2 parents 47e750b + d8f1681 commit 4d432d9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/crd/markers/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ var CRDMarkers = []*markers.Definition{

// TODO: categories and singular used to be annotations types
// TODO: doc
// TODO: nonNamespaced

func init() {
AllDefinitions = append(AllDefinitions, CRDMarkers...)
Expand Down Expand Up @@ -184,13 +183,21 @@ type Resource struct {
ShortName []string `marker:",optional"`
Categories []string `marker:",optional"`
Singular string `marker:",optional"`
Scope string `marker:",optional"`
}

func (s Resource) ApplyToCRD(crd *apiext.CustomResourceDefinitionSpec, version string) error {
crd.Names.Plural = s.Path
crd.Names.ShortNames = s.ShortName
crd.Names.Categories = s.Categories

switch s.Scope {
case "":
crd.Scope = apiext.NamespaceScoped
default:
crd.Scope = apiext.ResourceScope(s.Scope)
}

return nil
}

Expand Down

0 comments on commit 4d432d9

Please sign in to comment.