From bbc59cc83b4e801f87edd3a22b12a76c0683b27c Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Thu, 12 Mar 2026 15:37:10 +0100 Subject: [PATCH 1/5] Make the namespace for pattern operator subscription and for pattern CR a variable --- templates/pattern-operator-configmap.yaml | 2 +- templates/pattern.yaml | 2 +- templates/subscription.yaml | 4 +- tests/subscription_namespace_test.yaml | 69 +++++++++++++++++++++++ values.yaml | 2 + 5 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 tests/subscription_namespace_test.yaml diff --git a/templates/pattern-operator-configmap.yaml b/templates/pattern-operator-configmap.yaml index 0352920..46c38b4 100644 --- a/templates/pattern-operator-configmap.yaml +++ b/templates/pattern-operator-configmap.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: patterns-operator-config - namespace: openshift-operators + namespace: {{ .Values.main.patternsOperator.subscriptionNamespace }} data: gitops.catalogSource: {{ .Values.main.gitops.operatorSource }} gitops.channel: {{ .Values.main.gitops.channel }} diff --git a/templates/pattern.yaml b/templates/pattern.yaml index c7671c4..c1ea9fd 100644 --- a/templates/pattern.yaml +++ b/templates/pattern.yaml @@ -3,7 +3,7 @@ apiVersion: gitops.hybrid-cloud-patterns.io/v1alpha1 kind: Pattern metadata: name: {{ .Release.Name }} - namespace: openshift-operators + namespace: {{ .Values.main.patternsOperator.subscriptionNamespace }} spec: clusterGroupName: {{ .Values.main.clusterGroupName }} gitSpec: diff --git a/templates/subscription.yaml b/templates/subscription.yaml index e8285ca..c873553 100644 --- a/templates/subscription.yaml +++ b/templates/subscription.yaml @@ -2,9 +2,9 @@ apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: patterns-operator - namespace: openshift-operators + namespace: {{ .Values.main.patternsOperator.subscriptionNamespace }} labels: - operators.coreos.com/patterns-operator.openshift-operators: "" + operators.coreos.com/patterns-operator.{{ .Values.main.patternsOperator.subscriptionNamespace }}: "" spec: channel: {{ .Values.main.patternsOperator.channel }} installPlanApproval: {{ .Values.main.patternsOperator.installPlanApproval }} diff --git a/tests/subscription_namespace_test.yaml b/tests/subscription_namespace_test.yaml new file mode 100644 index 0000000..dc770d8 --- /dev/null +++ b/tests/subscription_namespace_test.yaml @@ -0,0 +1,69 @@ +suite: Test subscription namespace configuration +templates: + - templates/subscription.yaml + - templates/pattern.yaml + - templates/pattern-operator-configmap.yaml +tests: + - it: Should use default openshift-operators namespace for subscription + template: templates/subscription.yaml + asserts: + - equal: + path: metadata.namespace + value: openshift-operators + - equal: + path: metadata.labels["operators.coreos.com/patterns-operator.openshift-operators"] + value: "" + + - it: Should use custom namespace for subscription + template: templates/subscription.yaml + set: + main: + patternsOperator: + subscriptionNamespace: custom-namespace + asserts: + - equal: + path: metadata.namespace + value: custom-namespace + - equal: + path: metadata.labels["operators.coreos.com/patterns-operator.custom-namespace"] + value: "" + + - it: Should use default openshift-operators namespace for pattern + template: templates/pattern.yaml + release: + name: release-test + asserts: + - equal: + path: metadata.namespace + value: openshift-operators + + - it: Should use custom namespace for pattern + template: templates/pattern.yaml + release: + name: release-test + set: + main: + patternsOperator: + subscriptionNamespace: custom-namespace + asserts: + - equal: + path: metadata.namespace + value: custom-namespace + + - it: Should use default openshift-operators namespace for configmap + template: templates/pattern-operator-configmap.yaml + asserts: + - equal: + path: metadata.namespace + value: openshift-operators + + - it: Should use custom namespace for configmap + template: templates/pattern-operator-configmap.yaml + set: + main: + patternsOperator: + subscriptionNamespace: custom-namespace + asserts: + - equal: + path: metadata.namespace + value: custom-namespace diff --git a/values.yaml b/values.yaml index 589e002..b2244ac 100644 --- a/values.yaml +++ b/values.yaml @@ -60,6 +60,8 @@ main: installPlanApproval: Automatic # -- Source namespace to install the patterns operator from sourceNamespace: openshift-marketplace + # -- Namespace where the patterns operator subscription and related resources will be created + subscriptionNamespace: openshift-operators # -- Starting CSV for the install of the patterns operator startingCSV: null From 4b496e763023135880b3fbd1d3b8bf29a3088e48 Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Thu, 12 Mar 2026 15:38:31 +0100 Subject: [PATCH 2/5] Update the CRD from the operator --- crds/gitops.hybrid-cloud-patterns.io_patterns.yaml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/crds/gitops.hybrid-cloud-patterns.io_patterns.yaml b/crds/gitops.hybrid-cloud-patterns.io_patterns.yaml index f07e897..15957ab 100644 --- a/crds/gitops.hybrid-cloud-patterns.io_patterns.yaml +++ b/crds/gitops.hybrid-cloud-patterns.io_patterns.yaml @@ -225,14 +225,12 @@ spec: type: object type: array deletionPhase: - description: | - DeletionPhase tracks the current phase of pattern deletion. - Values: - "" (not deleting), - "DeleteSpokeChildApps" (Phase 1: Delete child applications from spoke clusters), - "DeleteSpoke" (Phase 2: Delete app of apps from spoke), - "DeleteHubChildApps" (Phase 3: Delete applications from hub), - "DeleteHub" (Phase 4: Delete app of apps from hub) + description: "DeletionPhase tracks the current phase of pattern deletion\nValues: + \"\" (not deleting), \"DeleteSpokeChildApps\" (Phase 1: Delete child + applications from spoke clusters), \"DeleteSpoke\" (Phase 2: Delete + app of apps from spoke),\n\t\t\t\t \"DeleteHubChildApps\" (Phase + 3: Delete applications from hub), \"DeleteHub\" (Phase 4: Delete + app of apps from hub)" type: string lastError: description: Last error encountered by the pattern From a15bee979d0272325db96923e49d94513b6070c0 Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Thu, 12 Mar 2026 16:51:28 +0100 Subject: [PATCH 3/5] Drop unneeded label --- templates/subscription.yaml | 2 -- tests/subscription_namespace_test.yaml | 6 ------ 2 files changed, 8 deletions(-) diff --git a/templates/subscription.yaml b/templates/subscription.yaml index c873553..f3da386 100644 --- a/templates/subscription.yaml +++ b/templates/subscription.yaml @@ -3,8 +3,6 @@ kind: Subscription metadata: name: patterns-operator namespace: {{ .Values.main.patternsOperator.subscriptionNamespace }} - labels: - operators.coreos.com/patterns-operator.{{ .Values.main.patternsOperator.subscriptionNamespace }}: "" spec: channel: {{ .Values.main.patternsOperator.channel }} installPlanApproval: {{ .Values.main.patternsOperator.installPlanApproval }} diff --git a/tests/subscription_namespace_test.yaml b/tests/subscription_namespace_test.yaml index dc770d8..fa8a187 100644 --- a/tests/subscription_namespace_test.yaml +++ b/tests/subscription_namespace_test.yaml @@ -10,9 +10,6 @@ tests: - equal: path: metadata.namespace value: openshift-operators - - equal: - path: metadata.labels["operators.coreos.com/patterns-operator.openshift-operators"] - value: "" - it: Should use custom namespace for subscription template: templates/subscription.yaml @@ -24,9 +21,6 @@ tests: - equal: path: metadata.namespace value: custom-namespace - - equal: - path: metadata.labels["operators.coreos.com/patterns-operator.custom-namespace"] - value: "" - it: Should use default openshift-operators namespace for pattern template: templates/pattern.yaml From 23f4e32faa95f185f02d28a06f235c24cc1e9b3b Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Thu, 12 Mar 2026 17:16:03 +0100 Subject: [PATCH 4/5] Add make explanation for test upload --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a4ad738..7f433fe 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ helm-package: ## Generates a local helm package .PHONY: helm-test-upload helm-test-upload: helm-package ## builds and uploads the helm package to HELM_TEST_REGISTRY which needs to be pre-set - if [ -z $(HELM_TEST_REGISTRY) ]; then echo "Please set HELM_TEST_REGISTRY"; exit 1; fi + if [ -z $(HELM_TEST_REGISTRY) ]; then echo "Please set HELM_TEST_REGISTRY (e.g. oci://quay.io/rhn_support_mbaldess/)"; exit 1; fi echo "Remember to login via helm: 'echo pass | helm registry login -u quay.io --password-stdin'" helm push $(CHART_NAME)-$(CHART_VERSION).tgz $(HELM_TEST_REGISTRY) From 60faf1ed5afe6ff7a747854680a8a83180315b41 Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Thu, 12 Mar 2026 20:33:48 +0100 Subject: [PATCH 5/5] Create NS and operatorGroup when outside of openshift-operators --- templates/subscription-namespace.yaml | 13 ++++++++++ tests/subscription_namespace_test.yaml | 35 ++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 templates/subscription-namespace.yaml diff --git a/templates/subscription-namespace.yaml b/templates/subscription-namespace.yaml new file mode 100644 index 0000000..c4568cb --- /dev/null +++ b/templates/subscription-namespace.yaml @@ -0,0 +1,13 @@ +{{- if ne .Values.main.patternsOperator.subscriptionNamespace "openshift-operators" }} +apiVersion: v1 +kind: Namespace +metadata: + name: {{ .Values.main.patternsOperator.subscriptionNamespace }} +--- +apiVersion: operators.coreos.com/v1 +kind: OperatorGroup +metadata: + name: patterns-operator-group + namespace: {{ .Values.main.patternsOperator.subscriptionNamespace }} +spec: {} +{{- end }} diff --git a/tests/subscription_namespace_test.yaml b/tests/subscription_namespace_test.yaml index fa8a187..d2dc6d3 100644 --- a/tests/subscription_namespace_test.yaml +++ b/tests/subscription_namespace_test.yaml @@ -3,6 +3,7 @@ templates: - templates/subscription.yaml - templates/pattern.yaml - templates/pattern-operator-configmap.yaml + - templates/subscription-namespace.yaml tests: - it: Should use default openshift-operators namespace for subscription template: templates/subscription.yaml @@ -61,3 +62,37 @@ tests: - equal: path: metadata.namespace value: custom-namespace + + - it: Should not create namespace when using default openshift-operators + template: templates/subscription-namespace.yaml + asserts: + - hasDocuments: + count: 0 + + - it: Should create namespace when using custom namespace + template: templates/subscription-namespace.yaml + set: + main: + patternsOperator: + subscriptionNamespace: custom-namespace + asserts: + - hasDocuments: + count: 2 + - isKind: + of: Namespace + documentIndex: 0 + - equal: + path: metadata.name + value: custom-namespace + documentIndex: 0 + - isKind: + of: OperatorGroup + documentIndex: 1 + - equal: + path: metadata.namespace + value: custom-namespace + documentIndex: 1 + - equal: + path: metadata.name + value: patterns-operator-group + documentIndex: 1