Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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<user> quay.io --password-stdin'"
helm push $(CHART_NAME)-$(CHART_VERSION).tgz $(HELM_TEST_REGISTRY)

Expand Down
14 changes: 6 additions & 8 deletions crds/gitops.hybrid-cloud-patterns.io_patterns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/pattern-operator-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion templates/pattern.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 13 additions & 0 deletions templates/subscription-namespace.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 1 addition & 3 deletions templates/subscription.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
98 changes: 98 additions & 0 deletions tests/subscription_namespace_test.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading