Skip to content

Commit 4d432d9

Browse files
authored
Merge pull request #220 from ironcladlou/crd-scope
✨ crd: add a resource scope marker
2 parents 47e750b + d8f1681 commit 4d432d9

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

pkg/crd/markers/crd.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ var CRDMarkers = []*markers.Definition{
3636

3737
// TODO: categories and singular used to be annotations types
3838
// TODO: doc
39-
// TODO: nonNamespaced
4039

4140
func init() {
4241
AllDefinitions = append(AllDefinitions, CRDMarkers...)
@@ -184,13 +183,21 @@ type Resource struct {
184183
ShortName []string `marker:",optional"`
185184
Categories []string `marker:",optional"`
186185
Singular string `marker:",optional"`
186+
Scope string `marker:",optional"`
187187
}
188188

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

194+
switch s.Scope {
195+
case "":
196+
crd.Scope = apiext.NamespaceScoped
197+
default:
198+
crd.Scope = apiext.ResourceScope(s.Scope)
199+
}
200+
194201
return nil
195202
}
196203

0 commit comments

Comments
 (0)