diff --git a/common/Makefile b/common/Makefile index af2c82f1..d07ca5cd 100644 --- a/common/Makefile +++ b/common/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 diff --git a/common/operator-install/templates/pattern.yaml b/common/operator-install/templates/pattern.yaml index e70f391d..3dc1948a 100644 --- a/common/operator-install/templates/pattern.yaml +++ b/common/operator-install/templates/pattern.yaml @@ -8,6 +8,10 @@ spec: gitSpec: targetRepo: {{ .Values.main.git.repoURL }} targetRevision: {{ .Values.main.git.revision }} +{{- 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 }} @@ -16,10 +20,6 @@ spec: {{- 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/common/tests/operator-install-industrial-edge-factory.expected.yaml b/common/tests/operator-install-industrial-edge-factory.expected.yaml index 1c57fe6b..71a8523e 100644 --- a/common/tests/operator-install-industrial-edge-factory.expected.yaml +++ b/common/tests/operator-install-industrial-edge-factory.expected.yaml @@ -24,7 +24,7 @@ spec: clusterGroupName: example gitSpec: targetRepo: https://github.com/pattern-clone/mypattern - targetRevision: main + targetRevision: main gitOpsSpec: operatorChannel: gitops-1.8 operatorSource: redhat-operators diff --git a/common/tests/operator-install-industrial-edge-hub.expected.yaml b/common/tests/operator-install-industrial-edge-hub.expected.yaml index 1c57fe6b..71a8523e 100644 --- a/common/tests/operator-install-industrial-edge-hub.expected.yaml +++ b/common/tests/operator-install-industrial-edge-hub.expected.yaml @@ -24,7 +24,7 @@ spec: clusterGroupName: example gitSpec: targetRepo: https://github.com/pattern-clone/mypattern - targetRevision: main + targetRevision: main gitOpsSpec: operatorChannel: gitops-1.8 operatorSource: redhat-operators diff --git a/common/tests/operator-install-medical-diagnosis-hub.expected.yaml b/common/tests/operator-install-medical-diagnosis-hub.expected.yaml index 1c57fe6b..71a8523e 100644 --- a/common/tests/operator-install-medical-diagnosis-hub.expected.yaml +++ b/common/tests/operator-install-medical-diagnosis-hub.expected.yaml @@ -24,7 +24,7 @@ spec: clusterGroupName: example gitSpec: targetRepo: https://github.com/pattern-clone/mypattern - targetRevision: main + targetRevision: main gitOpsSpec: operatorChannel: gitops-1.8 operatorSource: redhat-operators diff --git a/common/tests/operator-install-naked.expected.yaml b/common/tests/operator-install-naked.expected.yaml index 90fca51e..7523ec96 100644 --- a/common/tests/operator-install-naked.expected.yaml +++ b/common/tests/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/common/tests/operator-install-normal.expected.yaml b/common/tests/operator-install-normal.expected.yaml index 1c57fe6b..71a8523e 100644 --- a/common/tests/operator-install-normal.expected.yaml +++ b/common/tests/operator-install-normal.expected.yaml @@ -24,7 +24,7 @@ spec: clusterGroupName: example gitSpec: targetRepo: https://github.com/pattern-clone/mypattern - targetRevision: main + targetRevision: main gitOpsSpec: operatorChannel: gitops-1.8 operatorSource: redhat-operators