From 3546ee86b96f7fcb76ba31ede47e134d76b15890 Mon Sep 17 00:00:00 2001 From: Justin Kulikauskas Date: Tue, 30 Jan 2024 14:09:20 -0500 Subject: [PATCH] Add template label to CRD Required for the policy framework to distribute OperatorPolicies. Signed-off-by: Justin Kulikauskas --- deploy/crds/kustomize_operatorpolicy/kustomization.yaml | 6 ++++++ deploy/crds/kustomize_operatorpolicy/template-label.json | 7 +++++++ ...licy.open-cluster-management.io_operatorpolicies.yaml | 2 ++ test/e2e/case38_install_operator_test.go | 9 +++++++++ 4 files changed, 24 insertions(+) create mode 100644 deploy/crds/kustomize_operatorpolicy/template-label.json diff --git a/deploy/crds/kustomize_operatorpolicy/kustomization.yaml b/deploy/crds/kustomize_operatorpolicy/kustomization.yaml index ba26658e..e836fde8 100644 --- a/deploy/crds/kustomize_operatorpolicy/kustomization.yaml +++ b/deploy/crds/kustomize_operatorpolicy/kustomization.yaml @@ -9,3 +9,9 @@ patches: version: v1 kind: CustomResourceDefinition name: operatorpolicies.policy.open-cluster-management.io +- path: template-label.json + target: + group: apiextensions.k8s.io + version: v1 + kind: CustomResourceDefinition + name: operatorpolicies.policy.open-cluster-management.io diff --git a/deploy/crds/kustomize_operatorpolicy/template-label.json b/deploy/crds/kustomize_operatorpolicy/template-label.json new file mode 100644 index 00000000..7d9cc120 --- /dev/null +++ b/deploy/crds/kustomize_operatorpolicy/template-label.json @@ -0,0 +1,7 @@ +[ + { + "op":"add", + "path":"/metadata/labels", + "value": {"policy.open-cluster-management.io/policy-type": "template"} + } +] diff --git a/deploy/crds/policy.open-cluster-management.io_operatorpolicies.yaml b/deploy/crds/policy.open-cluster-management.io_operatorpolicies.yaml index 810d7074..54b4bbf1 100644 --- a/deploy/crds/policy.open-cluster-management.io_operatorpolicies.yaml +++ b/deploy/crds/policy.open-cluster-management.io_operatorpolicies.yaml @@ -6,6 +6,8 @@ metadata: annotations: controller-gen.kubebuilder.io/version: v0.6.1 creationTimestamp: null + labels: + policy.open-cluster-management.io/policy-type: template name: operatorpolicies.policy.open-cluster-management.io spec: group: policy.open-cluster-management.io diff --git a/test/e2e/case38_install_operator_test.go b/test/e2e/case38_install_operator_test.go index 9b863b50..1a5d1116 100644 --- a/test/e2e/case38_install_operator_test.go +++ b/test/e2e/case38_install_operator_test.go @@ -290,6 +290,15 @@ var _ = Describe("Test installing an operator from OperatorPolicy", Ordered, fun It("Should report a mismatch when the OperatorGroup is manually edited", func() { utils.Kubectl("patch", "operatorgroup", scopedOpGroupName, "-n", opPolTestNS, "--type=json", "-p", `[{"op": "replace", "path": "/spec/targetNamespaces", "value": []}]`) + + unstructGroup := utils.GetWithTimeout(clientManagedDynamic, gvrOperatorGroup, scopedOpGroupName, + opPolTestNS, true, opPolTimeout) + + groupJSON, err := json.MarshalIndent(unstructGroup.Object, "", " ") + Expect(err).NotTo(HaveOccurred()) + + GinkgoWriter.Printf("Debug info for failure.\noperatorGroup JSON: %s\n", string(groupJSON)) + check( opPolName, true,