From c127d6356fbf70a4609f41ee2f6d44c310d37194 Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Mon, 22 Dec 2025 09:53:34 +0100 Subject: [PATCH] Support customizing spoke gitops channel and source and release 0.1.13 --- Chart.yaml | 2 +- README.md | 7 ++- templates/policies/ocp-gitops-policy.yaml | 4 +- tests/ocp_gitops_policy_test.yaml | 76 ++++++++++++++++++++++- values.yaml | 9 ++- 5 files changed, 89 insertions(+), 9 deletions(-) diff --git a/Chart.yaml b/Chart.yaml index 435c4fa..e6f83b8 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -3,4 +3,4 @@ description: A Helm chart to configure Advanced Cluster Manager for OpenShift. keywords: - pattern name: acm -version: 0.1.12 +version: 0.1.13 diff --git a/README.md b/README.md index 82ec66d..7164207 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # acm -![Version: 0.1.12](https://img.shields.io/badge/Version-0.1.12-informational?style=flat-square) +![Version: 0.1.13](https://img.shields.io/badge/Version-0.1.13-informational?style=flat-square) A Helm chart to configure Advanced Cluster Manager for OpenShift. @@ -11,6 +11,8 @@ This chart is used by the Validated Patterns to configure ACM and manage remote | Key | Type | Default | Description | |-----|------|---------|-------------| | acm.mce_operator | object | Uses the official redhat sources | Just used for IIB testing, drives the source and channel for the MCE subscription triggered by ACM | +| acm.spokeGitops.channel | string | `"gitops-1.18"` | Default gitops channel to install on remote clusters | +| acm.spokeGitops.source | string | `"redhat-operators"` | | | clusterGroup | object | depends on the individual settings | Dictionary of all the clustergroups of the pattern | | clusterGroup.managedClusterGroups | object | `{}` | The set of cluters managed by ACM which is running inside this clusterGroup | | clusterGroup.subscriptions | object | `{"acm":{"source":"redhat-operators"}}` | Dictionary of subscriptions for this specific clusterGroup | @@ -22,7 +24,8 @@ This chart is used by the Validated Patterns to configure ACM and manage remote | global.repoURL | string | `"none"` | Repository URL pointing to the pattern | | global.secretStore.backend | string | `"vault"` | | | global.targetRevision | string | `"main"` | The branch or Git reference to use to deploy the pattern | -| main.gitops.channel | string | `"gitops-1.18"` | Default gitops channel to install on remote clusters | +| main | object | `{"gitops":{"channel":"gitops-1.18"}}` | Deprecated: Use acm.spokeGitops which takes precedence | +| main.gitops.channel | string | `"gitops-1.18"` | DEPRECATED: Default gitops channel to install on remote clusters (Use acm.spokeGitops.channel) | | secretStore | object | depends on the individual settings | Default secretstore configuration variables | | secretStore.name | string | `"vault-backend"` | Name of the clustersecretstore to be used for secrets | diff --git a/templates/policies/ocp-gitops-policy.yaml b/templates/policies/ocp-gitops-policy.yaml index 437ade7..aa555ac 100644 --- a/templates/policies/ocp-gitops-policy.yaml +++ b/templates/policies/ocp-gitops-policy.yaml @@ -37,10 +37,10 @@ spec: labels: operators.coreos.com/openshift-gitops-operator.openshift-operators: '' spec: - channel: {{ default "gitops-1.17" $.Values.main.gitops.channel }} + channel: {{- if and $.Values.acm.spokeGitops $.Values.acm.spokeGitops.channel }} {{ $.Values.acm.spokeGitops.channel }}{{- else if and $.Values.main $.Values.main.gitops $.Values.main.gitops.channel }} {{ $.Values.main.gitops.channel }}{{- else }} gitops-1.18{{- end }} installPlanApproval: Automatic name: openshift-gitops-operator - source: {{ default "redhat-operators" $.Values.main.gitops.operatorSource }} + source: {{- if and $.Values.acm.spokeGitops $.Values.acm.spokeGitops.source }} {{ $.Values.acm.spokeGitops.source }}{{- else if and $.Values.main $.Values.main.gitops $.Values.main.gitops.operatorSource }} {{ $.Values.main.gitops.operatorSource }}{{- else }} redhat-operators{{- end }} sourceNamespace: openshift-marketplace config: env: diff --git a/tests/ocp_gitops_policy_test.yaml b/tests/ocp_gitops_policy_test.yaml index c3d6788..26918bb 100644 --- a/tests/ocp_gitops_policy_test.yaml +++ b/tests/ocp_gitops_policy_test.yaml @@ -11,12 +11,12 @@ tests: - hasDocuments: count: 6 - - it: Should change the channel when specified + - it: Should change the channel when specified (legacy test updated to use spokeGitops) values: - ./clusterselector_values.yaml set: - main: - gitops: + acm: + spokeGitops: channel: gitops-9.9.9 asserts: - documentSelector: @@ -25,3 +25,73 @@ tests: equal: path: spec.policy-templates[0].objectDefinition.spec.object-templates[0].objectDefinition.spec.channel value: gitops-9.9.9 + + - it: Should use spokeGitops channel when specified + values: + - ./clusterselector_values.yaml + set: + acm: + spokeGitops: + channel: gitops-2.0.0 + asserts: + - documentSelector: + path: metadata.name + value: group-one-gitops-policy + equal: + path: spec.policy-templates[0].objectDefinition.spec.object-templates[0].objectDefinition.spec.channel + value: gitops-2.0.0 + + - it: Should use spokeGitops source when specified + values: + - ./clusterselector_values.yaml + set: + acm: + spokeGitops: + source: custom-operators + asserts: + - documentSelector: + path: metadata.name + value: group-one-gitops-policy + equal: + path: spec.policy-templates[0].objectDefinition.spec.object-templates[0].objectDefinition.spec.source + value: custom-operators + + - it: Should use spokeGitops channel and source when both specified + values: + - ./clusterselector_values.yaml + set: + acm: + spokeGitops: + channel: gitops-2.1.0 + source: my-custom-catalog + asserts: + - documentSelector: + path: metadata.name + value: group-one-gitops-policy + equal: + path: spec.policy-templates[0].objectDefinition.spec.object-templates[0].objectDefinition.spec.channel + value: gitops-2.1.0 + - documentSelector: + path: metadata.name + value: group-one-gitops-policy + equal: + path: spec.policy-templates[0].objectDefinition.spec.object-templates[0].objectDefinition.spec.source + value: my-custom-catalog + + - it: Should prioritize spokeGitops over main gitops settings + values: + - ./clusterselector_values.yaml + set: + main: + gitops: + channel: gitops-fallback + acm: + spokeGitops: + channel: gitops-priority + asserts: + - documentSelector: + path: metadata.name + value: group-one-gitops-policy + equal: + path: spec.policy-templates[0].objectDefinition.spec.object-templates[0].objectDefinition.spec.channel + value: gitops-priority diff --git a/values.yaml b/values.yaml index 5ab7fa0..2d81d26 100644 --- a/values.yaml +++ b/values.yaml @@ -1,6 +1,7 @@ +# -- Deprecated: Use acm.spokeGitops which takes precedence main: gitops: - # -- Default gitops channel to install on remote clusters + # -- DEPRECATED: Default gitops channel to install on remote clusters (Use acm.spokeGitops.channel) channel: "gitops-1.18" global: @@ -64,6 +65,12 @@ acm: source: redhat-operators channel: null + # @default -- Uses the official redhat source and some default channel + spokeGitops: + source: redhat-operators + # -- Default gitops channel to install on remote clusters + channel: "gitops-1.18" + # -- Default secretstore configuration variables # @default -- depends on the individual settings