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) 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 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-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/templates/subscription.yaml b/templates/subscription.yaml index e8285ca..f3da386 100644 --- a/templates/subscription.yaml +++ b/templates/subscription.yaml @@ -2,9 +2,7 @@ apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: patterns-operator - namespace: openshift-operators - labels: - operators.coreos.com/patterns-operator.openshift-operators: "" + namespace: {{ .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..d2dc6d3 --- /dev/null +++ b/tests/subscription_namespace_test.yaml @@ -0,0 +1,98 @@ +suite: Test subscription namespace configuration +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 + asserts: + - equal: + path: metadata.namespace + value: openshift-operators + + - 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 + + - 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 + + - 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 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