From c547ffe55a8df36fccb8e0bf264d843f15e31e45 Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Tue, 19 Dec 2023 18:45:21 +0100 Subject: [PATCH 1/4] Add support for private repo deployments via CLI A normal non-private deployment: ./pattern.sh make show helm template common/operator-install/ --name-template multicloud-gitops -f values-global.yaml --set main.git.repoURL="https://github.com/mbaldessari/multicloud-gitops.git" --set main.git.revision=private-repo-cli ... apiVersion: gitops.hybrid-cloud-patterns.io/v1alpha1 kind: Pattern metadata: name: multicloud-gitops namespace: openshift-operators spec: clusterGroupName: hub gitSpec: targetRepo: https://github.com/mbaldessari/multicloud-gitops.git targetRevision: private-repo-cli gitOpsSpec: operatorChannel: gitops-1.8 operatorSource: redhat-operators multiSourceConfig: enabled: true When we set the TOKEN_SECRET AND TOKEN_NAMESPACE env variables: ./pattern.sh make TOKEN_SECRET=foo TOKEN_NAMESPACE=bar show helm template common/operator-install/ --name-template multicloud-gitops -f values-global.yaml --set main.tokenSecret=foo --set main.tokenSecretNamespace=bar --set main.git.repoURL="git@github.com:mbaldessari/multicloud-gitops.git" --set main.git.revision=private-repo-cli ... apiVersion: gitops.hybrid-cloud-patterns.io/v1alpha1 kind: Pattern metadata: name: multicloud-gitops namespace: openshift-operators spec: clusterGroupName: hub gitSpec: targetRepo: git@github.com:mbaldessari/multicloud-gitops.git targetRevision: private-repo-cli gitOpsSpec: operatorChannel: gitops-1.8 operatorSource: redhat-operators multiSourceConfig: enabled: true tokenSecret: foo tokenSecretNamespace: bar In the latter case we do not rewrite the URL as it might an ssh-based one. --- Makefile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index af2c82f1..d07ca5cd 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,18 @@ ifneq ("$(wildcard $(UUID_FILE))","") UUID_HELM_OPTS := --set main.analyticsUUID=$(UUID) endif -HELM_OPTS=-f values-global.yaml --set main.git.repoURL="$(TARGET_REPO)" --set main.git.revision=$(TARGET_BRANCH) $(TARGET_SITE_OPT) $(UUID_HELM_OPTS) $(EXTRA_HELM_OPTS) +# Set the secret name *and* its namespace when deploying from private repositories +# The format of said secret is documented here: https://argo-cd.readthedocs.io/en/stable/operator-manual/declarative-setup/#repositories +TOKEN_SECRET ?= +TOKEN_NAMESPACE ?= + +ifeq ($(TOKEN_SECRET),) + HELM_OPTS=-f values-global.yaml --set main.git.repoURL="$(TARGET_REPO)" --set main.git.revision=$(TARGET_BRANCH) $(TARGET_SITE_OPT) $(UUID_HELM_OPTS) $(EXTRA_HELM_OPTS) +else + # When we are working with a private repository we do not escape the git URL as it might be using an ssh secret which does not use https:// + TARGET_CLEAN_REPO=$(shell git ls-remote --get-url --symref $(TARGET_ORIGIN)) + HELM_OPTS=-f values-global.yaml --set main.tokenSecret=$(TOKEN_SECRET) --set main.tokenSecretNamespace=$(TOKEN_NAMESPACE) --set main.git.repoURL="$(TARGET_CLEAN_REPO)" --set main.git.revision=$(TARGET_BRANCH) $(TARGET_SITE_OPT) $(UUID_HELM_OPTS) $(EXTRA_HELM_OPTS) +endif ##@ Pattern Common Tasks From cc067ff091ffc49098a523bedcd3b71dfc73918d Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Wed, 20 Dec 2023 11:33:16 +0100 Subject: [PATCH 2/4] Fix placement of tokenSecret material --- operator-install/templates/pattern.yaml | 8 ++++---- ...operator-install-industrial-edge-factory.expected.yaml | 2 +- tests/operator-install-industrial-edge-hub.expected.yaml | 2 +- .../operator-install-medical-diagnosis-hub.expected.yaml | 2 +- tests/operator-install-naked.expected.yaml | 2 +- tests/operator-install-normal.expected.yaml | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/operator-install/templates/pattern.yaml b/operator-install/templates/pattern.yaml index e70f391d..bf35b3cd 100644 --- a/operator-install/templates/pattern.yaml +++ b/operator-install/templates/pattern.yaml @@ -11,15 +11,15 @@ spec: gitOpsSpec: operatorChannel: {{ default "gitops-1.8" .Values.main.gitops.channel }} operatorSource: {{ default "redhat-operators" .Values.main.gitops.operatorSource }} +{{- if and .Values.main.tokenSecret .Values.main.tokenSecretNamespace }} + tokenSecret: {{ .Values.main.tokenSecret }} + tokenSecretNamespace: {{ .Values.main.tokenSecretNamespace }} +{{- end }} {{/* if and .Values.main.tokenSecret .Values.main.tokenSecretNamespace */}} multiSourceConfig: enabled: {{ .Values.main.multiSourceConfig.enabled }} {{- if .Values.main.analyticsUUID }} analyticsUUID: {{ .Values.main.analyticsUUID }} {{- end }} {{/* if .Values.main.analyticsUUID */}} -{{- if and .Values.main.tokenSecret .Values.main.tokenSecretNamespace }} - tokenSecret: {{ .Values.main.tokenSecret }} - tokenSecretNamespace: {{ .Values.main.tokenSecretNamespace }} -{{- end }} {{/* if and .Values.main.tokenSecret .Values.main.tokenSecretNamespace */}} {{- if .Values.main.extraParameters }} extraParameters: {{- range .Values.main.extraParameters }} diff --git a/tests/operator-install-industrial-edge-factory.expected.yaml b/tests/operator-install-industrial-edge-factory.expected.yaml index 1c57fe6b..6c6b10a9 100644 --- a/tests/operator-install-industrial-edge-factory.expected.yaml +++ b/tests/operator-install-industrial-edge-factory.expected.yaml @@ -27,7 +27,7 @@ spec: targetRevision: main gitOpsSpec: operatorChannel: gitops-1.8 - operatorSource: redhat-operators + operatorSource: redhat-operators multiSourceConfig: enabled: false --- diff --git a/tests/operator-install-industrial-edge-hub.expected.yaml b/tests/operator-install-industrial-edge-hub.expected.yaml index 1c57fe6b..6c6b10a9 100644 --- a/tests/operator-install-industrial-edge-hub.expected.yaml +++ b/tests/operator-install-industrial-edge-hub.expected.yaml @@ -27,7 +27,7 @@ spec: targetRevision: main gitOpsSpec: operatorChannel: gitops-1.8 - operatorSource: redhat-operators + operatorSource: redhat-operators multiSourceConfig: enabled: false --- diff --git a/tests/operator-install-medical-diagnosis-hub.expected.yaml b/tests/operator-install-medical-diagnosis-hub.expected.yaml index 1c57fe6b..6c6b10a9 100644 --- a/tests/operator-install-medical-diagnosis-hub.expected.yaml +++ b/tests/operator-install-medical-diagnosis-hub.expected.yaml @@ -27,7 +27,7 @@ spec: targetRevision: main gitOpsSpec: operatorChannel: gitops-1.8 - operatorSource: redhat-operators + operatorSource: redhat-operators multiSourceConfig: enabled: false --- diff --git a/tests/operator-install-naked.expected.yaml b/tests/operator-install-naked.expected.yaml index 90fca51e..c7ae9159 100644 --- a/tests/operator-install-naked.expected.yaml +++ b/tests/operator-install-naked.expected.yaml @@ -27,7 +27,7 @@ spec: targetRevision: main gitOpsSpec: operatorChannel: gitops-1.8 - operatorSource: redhat-operators + operatorSource: redhat-operators multiSourceConfig: enabled: false --- diff --git a/tests/operator-install-normal.expected.yaml b/tests/operator-install-normal.expected.yaml index 1c57fe6b..6c6b10a9 100644 --- a/tests/operator-install-normal.expected.yaml +++ b/tests/operator-install-normal.expected.yaml @@ -27,7 +27,7 @@ spec: targetRevision: main gitOpsSpec: operatorChannel: gitops-1.8 - operatorSource: redhat-operators + operatorSource: redhat-operators multiSourceConfig: enabled: false --- From eef7bb4544ede0909a7c11c117b097f052c457f7 Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Wed, 20 Dec 2023 11:47:32 +0100 Subject: [PATCH 3/4] Fix placement of tokenSecret material in the right section --- operator-install/templates/pattern.yaml | 6 +++--- .../operator-install-industrial-edge-factory.expected.yaml | 4 ++-- tests/operator-install-industrial-edge-hub.expected.yaml | 4 ++-- tests/operator-install-medical-diagnosis-hub.expected.yaml | 4 ++-- tests/operator-install-naked.expected.yaml | 4 ++-- tests/operator-install-normal.expected.yaml | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/operator-install/templates/pattern.yaml b/operator-install/templates/pattern.yaml index bf35b3cd..3dc1948a 100644 --- a/operator-install/templates/pattern.yaml +++ b/operator-install/templates/pattern.yaml @@ -8,13 +8,13 @@ spec: gitSpec: targetRepo: {{ .Values.main.git.repoURL }} targetRevision: {{ .Values.main.git.revision }} - gitOpsSpec: - operatorChannel: {{ default "gitops-1.8" .Values.main.gitops.channel }} - operatorSource: {{ default "redhat-operators" .Values.main.gitops.operatorSource }} {{- if and .Values.main.tokenSecret .Values.main.tokenSecretNamespace }} tokenSecret: {{ .Values.main.tokenSecret }} tokenSecretNamespace: {{ .Values.main.tokenSecretNamespace }} {{- end }} {{/* if and .Values.main.tokenSecret .Values.main.tokenSecretNamespace */}} + gitOpsSpec: + operatorChannel: {{ default "gitops-1.8" .Values.main.gitops.channel }} + operatorSource: {{ default "redhat-operators" .Values.main.gitops.operatorSource }} multiSourceConfig: enabled: {{ .Values.main.multiSourceConfig.enabled }} {{- if .Values.main.analyticsUUID }} diff --git a/tests/operator-install-industrial-edge-factory.expected.yaml b/tests/operator-install-industrial-edge-factory.expected.yaml index 6c6b10a9..71a8523e 100644 --- a/tests/operator-install-industrial-edge-factory.expected.yaml +++ b/tests/operator-install-industrial-edge-factory.expected.yaml @@ -24,10 +24,10 @@ spec: clusterGroupName: example gitSpec: targetRepo: https://github.com/pattern-clone/mypattern - targetRevision: main + targetRevision: main gitOpsSpec: operatorChannel: gitops-1.8 - operatorSource: redhat-operators + operatorSource: redhat-operators multiSourceConfig: enabled: false --- diff --git a/tests/operator-install-industrial-edge-hub.expected.yaml b/tests/operator-install-industrial-edge-hub.expected.yaml index 6c6b10a9..71a8523e 100644 --- a/tests/operator-install-industrial-edge-hub.expected.yaml +++ b/tests/operator-install-industrial-edge-hub.expected.yaml @@ -24,10 +24,10 @@ spec: clusterGroupName: example gitSpec: targetRepo: https://github.com/pattern-clone/mypattern - targetRevision: main + targetRevision: main gitOpsSpec: operatorChannel: gitops-1.8 - operatorSource: redhat-operators + operatorSource: redhat-operators multiSourceConfig: enabled: false --- diff --git a/tests/operator-install-medical-diagnosis-hub.expected.yaml b/tests/operator-install-medical-diagnosis-hub.expected.yaml index 6c6b10a9..71a8523e 100644 --- a/tests/operator-install-medical-diagnosis-hub.expected.yaml +++ b/tests/operator-install-medical-diagnosis-hub.expected.yaml @@ -24,10 +24,10 @@ spec: clusterGroupName: example gitSpec: targetRepo: https://github.com/pattern-clone/mypattern - targetRevision: main + targetRevision: main gitOpsSpec: operatorChannel: gitops-1.8 - operatorSource: redhat-operators + operatorSource: redhat-operators multiSourceConfig: enabled: false --- diff --git a/tests/operator-install-naked.expected.yaml b/tests/operator-install-naked.expected.yaml index c7ae9159..7523ec96 100644 --- a/tests/operator-install-naked.expected.yaml +++ b/tests/operator-install-naked.expected.yaml @@ -24,10 +24,10 @@ spec: clusterGroupName: default gitSpec: targetRepo: https://github.com/pattern-clone/mypattern - targetRevision: main + targetRevision: main gitOpsSpec: operatorChannel: gitops-1.8 - operatorSource: redhat-operators + operatorSource: redhat-operators multiSourceConfig: enabled: false --- diff --git a/tests/operator-install-normal.expected.yaml b/tests/operator-install-normal.expected.yaml index 6c6b10a9..71a8523e 100644 --- a/tests/operator-install-normal.expected.yaml +++ b/tests/operator-install-normal.expected.yaml @@ -24,10 +24,10 @@ spec: clusterGroupName: example gitSpec: targetRepo: https://github.com/pattern-clone/mypattern - targetRevision: main + targetRevision: main gitOpsSpec: operatorChannel: gitops-1.8 - operatorSource: redhat-operators + operatorSource: redhat-operators multiSourceConfig: enabled: false --- From 6e45c450c461ae2750e04d94fff0cb8ed4a46178 Mon Sep 17 00:00:00 2001 From: Lester Claudio Date: Thu, 21 Dec 2023 14:24:11 -0700 Subject: [PATCH 4/4] CI test updates --- ...ommon-operator-install-industrial-edge-factory.expected.yaml | 2 +- tests/common-operator-install-industrial-edge-hub.expected.yaml | 2 +- .../common-operator-install-medical-diagnosis-hub.expected.yaml | 2 +- tests/common-operator-install-naked.expected.yaml | 2 +- tests/common-operator-install-normal.expected.yaml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/common-operator-install-industrial-edge-factory.expected.yaml b/tests/common-operator-install-industrial-edge-factory.expected.yaml index 1a4aa65c..fcfc9496 100644 --- a/tests/common-operator-install-industrial-edge-factory.expected.yaml +++ b/tests/common-operator-install-industrial-edge-factory.expected.yaml @@ -24,7 +24,7 @@ spec: clusterGroupName: hub gitSpec: targetRepo: https://github.com/pattern-clone/mypattern - targetRevision: main + targetRevision: main gitOpsSpec: operatorChannel: gitops-1.8 operatorSource: redhat-operators diff --git a/tests/common-operator-install-industrial-edge-hub.expected.yaml b/tests/common-operator-install-industrial-edge-hub.expected.yaml index 1a4aa65c..fcfc9496 100644 --- a/tests/common-operator-install-industrial-edge-hub.expected.yaml +++ b/tests/common-operator-install-industrial-edge-hub.expected.yaml @@ -24,7 +24,7 @@ spec: clusterGroupName: hub gitSpec: targetRepo: https://github.com/pattern-clone/mypattern - targetRevision: main + targetRevision: main gitOpsSpec: operatorChannel: gitops-1.8 operatorSource: redhat-operators diff --git a/tests/common-operator-install-medical-diagnosis-hub.expected.yaml b/tests/common-operator-install-medical-diagnosis-hub.expected.yaml index 1a4aa65c..fcfc9496 100644 --- a/tests/common-operator-install-medical-diagnosis-hub.expected.yaml +++ b/tests/common-operator-install-medical-diagnosis-hub.expected.yaml @@ -24,7 +24,7 @@ spec: clusterGroupName: hub gitSpec: targetRepo: https://github.com/pattern-clone/mypattern - targetRevision: main + targetRevision: main gitOpsSpec: operatorChannel: gitops-1.8 operatorSource: redhat-operators diff --git a/tests/common-operator-install-naked.expected.yaml b/tests/common-operator-install-naked.expected.yaml index 6cf7ba0a..5a620dfa 100644 --- a/tests/common-operator-install-naked.expected.yaml +++ b/tests/common-operator-install-naked.expected.yaml @@ -24,7 +24,7 @@ spec: clusterGroupName: default gitSpec: targetRepo: https://github.com/pattern-clone/mypattern - targetRevision: main + targetRevision: main gitOpsSpec: operatorChannel: gitops-1.8 operatorSource: redhat-operators diff --git a/tests/common-operator-install-normal.expected.yaml b/tests/common-operator-install-normal.expected.yaml index 1a4aa65c..fcfc9496 100644 --- a/tests/common-operator-install-normal.expected.yaml +++ b/tests/common-operator-install-normal.expected.yaml @@ -24,7 +24,7 @@ spec: clusterGroupName: hub gitSpec: targetRepo: https://github.com/pattern-clone/mypattern - targetRevision: main + targetRevision: main gitOpsSpec: operatorChannel: gitops-1.8 operatorSource: redhat-operators