Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbw976/7487710e00e93904f17ca2b86957f4e6 to your computer and use it in GitHub Desktop.
Save jbw976/7487710e00e93904f17ca2b86957f4e6 to your computer and use it in GitHub Desktop.
allow cluster scoped CRDs for cluster scoped stacks
> git diff
diff --git a/pkg/stacks/steps.go b/pkg/stacks/steps.go
index a89ab1ec..31a7a676 100644
--- a/pkg/stacks/steps.go
+++ b/pkg/stacks/steps.go
@@ -81,10 +81,6 @@ func crdStep(sp StackPackager) walker.Step {
return errors.Wrap(err, fmt.Sprintf("invalid crd %q", path))
}
- if (crd.Spec.Scope != apiextensions.NamespaceScoped) && (crd.Spec.Scope != "") {
- return errors.New(fmt.Sprintf("Stack CRD %q must be namespaced scope", path))
- }
-
sp.AddCRD(filepath.Dir(path), crd)
return nil
}
diff --git a/pkg/stacks/unpack.go b/pkg/stacks/unpack.go
index dcb87c46..8b68d776 100644
--- a/pkg/stacks/unpack.go
+++ b/pkg/stacks/unpack.go
@@ -273,6 +273,12 @@ func (sp *StackPackage) AddIcon(path string, icon v1alpha1.IconSpec) {
// AddCRD appends a CRD to the CRDs of this StackPackage
// The CRD will be annotated before being added and the Stack will track ownership of this CRD.
func (sp *StackPackage) AddCRD(path string, crd *apiextensions.CustomResourceDefinition) {
+
+ if sp.Stack.Spec.PermissionScope == "Namespaced" &&
+ (crd.Spec.Scope != apiextensions.NamespaceScoped || crd.Spec.Scope == "") {
+ return errors.New(fmt.Sprintf("Stack CRD %q must be namespaced scope", path))
+ }
+
if crd.ObjectMeta.Annotations == nil {
crd.ObjectMeta.Annotations = map[string]string{}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment