From 025c33c0e3b4064a8c86632de989140691079f47 Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Tue, 30 Jun 2026 16:27:48 +0200 Subject: [PATCH 1/2] Add variant support When .main.variant is set we use that, otherwise we use the usual older .main.clusterGroupName I make both of their default values set to null as that makes it possible to detect the case when the user mistakenly sets both values. It is safe to do since we always set it in values-global.yaml anyways. The user of the variant field will require the pattern operator 0.0.78 --- README.md | 3 +- ...ops.hybrid-cloud-patterns.io_patterns.yaml | 3 +- templates/pattern.yaml | 6 ++++ tests/pattern_custom_values_test.yaml | 28 ++++++++++++++++++- tests/pattern_default_test.yaml | 5 ++-- values.yaml | 9 ++++-- 6 files changed, 47 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e36c8c6..b0bd616 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ This chart is used by the Validated Patterns installation script that can be fou | main | object | depends on the individual settings | main is used primarily for initial bootstrap pattern configuration | | main.analytics | object | `{"enabled":true}` | Settings related to the segment.io analytics collection by the patterns operator | | main.analytics.enabled | bool | `true` | Whether analytics are enabled or not | -| main.clusterGroupName | string | `"default"` | Name of the clusterGroup to be used. Drives the clusterGroup chart | +| main.clusterGroupName | DEPRECATED | `nil` | Name of the clusterGroup to be used. Drives the clusterGroup chart. Use main.variant instead. Cannot be set together with main.variant. | | main.experimentalCapabilities | string | `""` | String to enable certain experimental capabilities in the operator and the framework. Not needed unless you know exactly what you're doing. | | main.git | object | depends on the individual settings | Settings related to the Git repository used to deploy the pattern | | main.git.repoURL | string | `"https://github.com/pattern-clone/mypattern"` | Repository URL pointing to the pattern | @@ -48,6 +48,7 @@ This chart is used by the Validated Patterns installation script that can be fou | main.patternsOperator.subscriptionNamespace | string | `"openshift-operators"` | Namespace where the patterns operator subscription and related resources will be created | | main.tokenSecret | string | `nil` | Name of the secret containing access credentials to clone the Git repository to deploy the pattern See https://validatedpatterns.io/blog/2023-12-20-private-repos/ for more information | | main.tokenSecretNamespace | string | `nil` | Namespace where the above secret will be | +| main.variant | string | `nil` | Name of the variant to be used. Drives the clusterGroup chart. Replaces main.clusterGroupName. Cannot be set together with main.clusterGroupName. | ---------------------------------------------- Autogenerated from chart metadata using [helm-docs v1.14.2](https://github.com/norwoodj/helm-docs/releases/v1.14.2) diff --git a/crds/gitops.hybrid-cloud-patterns.io_patterns.yaml b/crds/gitops.hybrid-cloud-patterns.io_patterns.yaml index 7bfe26b..bb724ab 100644 --- a/crds/gitops.hybrid-cloud-patterns.io_patterns.yaml +++ b/crds/gitops.hybrid-cloud-patterns.io_patterns.yaml @@ -56,6 +56,8 @@ spec: type: string clusterGroupName: type: string + variant: + type: string experimentalCapabilities: description: Comma separated capabilities to enable certain experimental features @@ -153,7 +155,6 @@ spec: type: string type: object required: - - clusterGroupName - gitSpec type: object status: diff --git a/templates/pattern.yaml b/templates/pattern.yaml index c1ea9fd..9b65629 100644 --- a/templates/pattern.yaml +++ b/templates/pattern.yaml @@ -5,7 +5,13 @@ metadata: name: {{ .Release.Name }} namespace: {{ .Values.main.patternsOperator.subscriptionNamespace }} spec: +{{- if and .Values.main.variant .Values.main.clusterGroupName }} + {{- fail "main.variant and main.clusterGroupName are mutually exclusive, please set only one" }} +{{- else if .Values.main.variant }} + variant: {{ .Values.main.variant }} +{{- else if .Values.main.clusterGroupName }} clusterGroupName: {{ .Values.main.clusterGroupName }} +{{- end }} gitSpec: {{- if .Values.main.git.repoUpstreamURL }} originRepo: {{ .Values.main.git.repoUpstreamURL }} diff --git a/tests/pattern_custom_values_test.yaml b/tests/pattern_custom_values_test.yaml index d8f2eee..d069a67 100644 --- a/tests/pattern_custom_values_test.yaml +++ b/tests/pattern_custom_values_test.yaml @@ -4,9 +4,10 @@ templates: release: name: release-custom-test tests: - - it: "should render Pattern with required fields" + - it: "should render Pattern with clusterGroupName when main.clusterGroupName is set" set: main.clusterGroupName: "my-cluster-group" + main.variant: null main.git.repoURL: "https://github.com/example/repo.git" main.git.revision: "main" main.multiSourceConfig.enabled: true @@ -22,6 +23,8 @@ tests: - equal: path: spec.clusterGroupName value: "my-cluster-group" + - notExists: + path: spec.variant - equal: path: spec.gitSpec.targetRepo value: "https://github.com/example/repo.git" @@ -36,6 +39,29 @@ tests: - notExists: path: spec.multiSourceConfig.clusterGroupChartGitRevision + - it: "should render Pattern with variant when main.variant is set" + set: + main.variant: "my-variant" + main.git.repoURL: "https://github.com/example/repo.git" + main.git.revision: "main" + main.multiSourceConfig.enabled: true + asserts: + - isKind: + of: Pattern + - equal: + path: spec.variant + value: "my-variant" + - notExists: + path: spec.clusterGroupName + + - it: "should fail when both main.variant and main.clusterGroupName are set" + set: + main.variant: "my-variant" + main.clusterGroupName: "my-cluster-group" + asserts: + - failedTemplate: + errorMessage: "main.variant and main.clusterGroupName are mutually exclusive, please set only one" + - it: "should not include clusterGroupGitRepoUrl and clusterGroupChartGitRevision when clusterGroupChartVersion is set" set: main.multiSourceConfig.clusterGroupChartVersion: "6.6.6" diff --git a/tests/pattern_default_test.yaml b/tests/pattern_default_test.yaml index 109e434..62f8fa3 100644 --- a/tests/pattern_default_test.yaml +++ b/tests/pattern_default_test.yaml @@ -15,9 +15,10 @@ tests: apiVersion: gitops.hybrid-cloud-patterns.io/v1alpha1 name: release-test namespace: openshift-operators - - equal: + - notExists: + path: spec.variant + - notExists: path: spec.clusterGroupName - value: default - equal: path: spec.gitSpec.targetRepo value: https://github.com/pattern-clone/mypattern diff --git a/values.yaml b/values.yaml index fc89bfe..f84d881 100644 --- a/values.yaml +++ b/values.yaml @@ -68,8 +68,13 @@ main: # -- Starting CSV for the install of the patterns operator startingCSV: null - # -- Name of the clusterGroup to be used. Drives the clusterGroup chart - clusterGroupName: default + # -- (DEPRECATED) Name of the clusterGroup to be used. Drives the clusterGroup chart. + # Use main.variant instead. Cannot be set together with main.variant. + clusterGroupName: null + + # -- Name of the variant to be used. Drives the clusterGroup chart. + # Replaces main.clusterGroupName. Cannot be set together with main.clusterGroupName. + variant: null # -- Name of the secret containing access credentials to clone the Git repository to deploy the pattern # See https://validatedpatterns.io/blog/2023-12-20-private-repos/ for more information From ce527eaf769daf1e56b08ada210107a92840f749 Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Thu, 2 Jul 2026 15:59:40 +0200 Subject: [PATCH 2/2] Error out if both clusterGroupName and variant are unset --- templates/pattern.yaml | 2 ++ tests/pattern_custom_values_test.yaml | 21 +++++++++++++++++++++ tests/pattern_default_test.yaml | 5 ++++- tests/pattern_no_cr_test.yaml | 2 ++ tests/pattern_snapshot_test.yaml | 2 ++ tests/subscription_namespace_test.yaml | 17 +++++++++++++++++ 6 files changed, 48 insertions(+), 1 deletion(-) diff --git a/templates/pattern.yaml b/templates/pattern.yaml index 9b65629..b468e1c 100644 --- a/templates/pattern.yaml +++ b/templates/pattern.yaml @@ -11,6 +11,8 @@ spec: variant: {{ .Values.main.variant }} {{- else if .Values.main.clusterGroupName }} clusterGroupName: {{ .Values.main.clusterGroupName }} +{{- else }} + {{- fail "either main.variant or main.clusterGroupName must be set" }} {{- end }} gitSpec: {{- if .Values.main.git.repoUpstreamURL }} diff --git a/tests/pattern_custom_values_test.yaml b/tests/pattern_custom_values_test.yaml index d069a67..6eac828 100644 --- a/tests/pattern_custom_values_test.yaml +++ b/tests/pattern_custom_values_test.yaml @@ -62,8 +62,17 @@ tests: - failedTemplate: errorMessage: "main.variant and main.clusterGroupName are mutually exclusive, please set only one" + - it: "should fail when neither main.variant nor main.clusterGroupName is set" + set: + main.variant: null + main.clusterGroupName: null + asserts: + - failedTemplate: + errorMessage: "either main.variant or main.clusterGroupName must be set" + - it: "should not include clusterGroupGitRepoUrl and clusterGroupChartGitRevision when clusterGroupChartVersion is set" set: + main.variant: "default" main.multiSourceConfig.clusterGroupChartVersion: "6.6.6" asserts: - notExists: @@ -73,6 +82,7 @@ tests: - it: "should include clusterGroupGitRepoUrl and clusterGroupChartGitRevision when clusterGroupChartVersion is not set" set: + main.variant: "default" main.multiSourceConfig.clusterGroupChartGitRevision: "test-branch" main.multiSourceConfig.clusterGroupGitRepoUrl: "https://github.com/custom/clustergroup-chart" asserts: @@ -87,6 +97,7 @@ tests: - it: "should include originRepo when repoUpstreamURL is set" set: + main.variant: "default" main.git.repoUpstreamURL: "https://github.com/example/upstream.git" asserts: - exists: @@ -97,6 +108,7 @@ tests: - it: "should not include tokenSecret and tokenSecretNamespace when only tokenSecret is set" set: + main.variant: "default" main.tokenSecret: "my-token-secret" asserts: - notExists: @@ -106,6 +118,7 @@ tests: - it: "should not include tokenSecret and tokenSecretNamespace when only tokenSecretNamespace is set" set: + main.variant: "default" main.tokenSecretNamespace: "my-token-namespace" asserts: - notExists: @@ -115,6 +128,7 @@ tests: - it: "should include tokenSecret and tokenSecretNamespace when both are set" set: + main.variant: "default" main.tokenSecret: "my-token-secret" main.tokenSecretNamespace: "my-token-namespace" asserts: @@ -131,6 +145,7 @@ tests: - it: "should include helmRepoUrl when multiSourceConfig.helmRepoUrl is set" set: + main.variant: "default" main.multiSourceConfig.helmRepoUrl: "https://charts.example.com/" asserts: - exists: @@ -141,6 +156,7 @@ tests: - it: "should include clusterGroupChartVersion when set" set: + main.variant: "default" main.multiSourceConfig.clusterGroupChartVersion: "1.0.0" asserts: - exists: @@ -151,6 +167,7 @@ tests: - it: "should include analyticsUUID when set" set: + main.variant: "default" main.analyticsUUID: "uuid-1234" asserts: - exists: @@ -161,6 +178,7 @@ tests: - it: "should include experimentalCapabilities when set" set: + main.variant: "default" main.experimentalCapabilities: "some-feature" asserts: - exists: @@ -172,6 +190,7 @@ tests: - it: "should include extraParameters when set" set: main: + variant: "default" extraParameters: - name: "param1" value: "value1" @@ -195,6 +214,8 @@ tests: - it: "should include extraValueFiles when set" set: + main: + variant: "default" global: extraValueFiles: - "file1.yaml" diff --git a/tests/pattern_default_test.yaml b/tests/pattern_default_test.yaml index 62f8fa3..ad16e43 100644 --- a/tests/pattern_default_test.yaml +++ b/tests/pattern_default_test.yaml @@ -5,6 +5,8 @@ release: name: release-test tests: - it: Should output default values + set: + main.variant: "default" asserts: - hasDocuments: count: 1 @@ -15,8 +17,9 @@ tests: apiVersion: gitops.hybrid-cloud-patterns.io/v1alpha1 name: release-test namespace: openshift-operators - - notExists: + - equal: path: spec.variant + value: "default" - notExists: path: spec.clusterGroupName - equal: diff --git a/tests/pattern_no_cr_test.yaml b/tests/pattern_no_cr_test.yaml index 55695c3..972b90a 100644 --- a/tests/pattern_no_cr_test.yaml +++ b/tests/pattern_no_cr_test.yaml @@ -17,6 +17,7 @@ tests: - it: Should output a pattern if repoURL is set set: main: + variant: "default" git: repoURL: foo.bar asserts: @@ -33,6 +34,7 @@ tests: - it: Should output a pattern if repoUpstreamURL is set set: main: + variant: "default" git: repoUpstreamURL: foo.bar asserts: diff --git a/tests/pattern_snapshot_test.yaml b/tests/pattern_snapshot_test.yaml index 7ced1b8..b01bf4a 100644 --- a/tests/pattern_snapshot_test.yaml +++ b/tests/pattern_snapshot_test.yaml @@ -5,6 +5,8 @@ release: name: release-test tests: - it: gitspec.targetRepo should match snapshot + set: + main.variant: "default" asserts: - matchSnapshot: path: spec.gitSpec.targetRepo diff --git a/tests/subscription_namespace_test.yaml b/tests/subscription_namespace_test.yaml index 3e63720..310c750 100644 --- a/tests/subscription_namespace_test.yaml +++ b/tests/subscription_namespace_test.yaml @@ -7,6 +7,8 @@ templates: tests: - it: Should use default openshift-operators namespace for subscription template: templates/subscription.yaml + set: + main.variant: "default" asserts: - equal: path: metadata.namespace @@ -16,6 +18,7 @@ tests: template: templates/subscription.yaml set: main: + variant: "default" patternsOperator: subscriptionNamespace: custom-namespace asserts: @@ -27,6 +30,8 @@ tests: template: templates/pattern.yaml release: name: release-test + set: + main.variant: "default" asserts: - equal: path: metadata.namespace @@ -38,6 +43,7 @@ tests: name: release-test set: main: + variant: "default" patternsOperator: subscriptionNamespace: custom-namespace asserts: @@ -47,6 +53,8 @@ tests: - it: Should use default openshift-operators namespace for configmap template: templates/pattern-operator-configmap.yaml + set: + main.variant: "default" asserts: - equal: path: metadata.namespace @@ -56,6 +64,7 @@ tests: template: templates/pattern-operator-configmap.yaml set: main: + variant: "default" patternsOperator: subscriptionNamespace: custom-namespace asserts: @@ -65,6 +74,8 @@ tests: - it: Should not create namespace when using default openshift-operators template: templates/subscription-namespace.yaml + set: + main.variant: "default" asserts: - hasDocuments: count: 0 @@ -73,6 +84,7 @@ tests: template: templates/subscription-namespace.yaml set: main: + variant: "default" patternsOperator: subscriptionNamespace: custom-namespace asserts: @@ -101,6 +113,7 @@ tests: template: templates/subscription-namespace.yaml set: main: + variant: "default" patternsOperator: enableSubscription: false asserts: @@ -111,6 +124,7 @@ tests: template: templates/subscription-namespace.yaml set: main: + variant: "default" patternsOperator: enableSubscription: false subscriptionNamespace: custom-namespace @@ -122,6 +136,7 @@ tests: template: templates/subscription.yaml set: main: + variant: "default" patternsOperator: enableSubscription: false asserts: @@ -134,6 +149,7 @@ tests: name: release-test set: main: + variant: "default" patternsOperator: enableSubscription: false asserts: @@ -146,6 +162,7 @@ tests: template: templates/pattern-operator-configmap.yaml set: main: + variant: "default" patternsOperator: enableSubscription: false asserts: