Created
October 22, 2019 05:37
-
-
Save jbw976/7487710e00e93904f17ca2b86957f4e6 to your computer and use it in GitHub Desktop.
allow cluster scoped CRDs for cluster scoped stacks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> 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