Skip to content

Commit c547ffe

Browse files
committed
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.
1 parent 9ef16ba commit c547ffe

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,18 @@ ifneq ("$(wildcard $(UUID_FILE))","")
2828
UUID_HELM_OPTS := --set main.analyticsUUID=$(UUID)
2929
endif
3030

31-
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)
31+
# Set the secret name *and* its namespace when deploying from private repositories
32+
# The format of said secret is documented here: https://argo-cd.readthedocs.io/en/stable/operator-manual/declarative-setup/#repositories
33+
TOKEN_SECRET ?=
34+
TOKEN_NAMESPACE ?=
35+
36+
ifeq ($(TOKEN_SECRET),)
37+
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)
38+
else
39+
# 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://
40+
TARGET_CLEAN_REPO=$(shell git ls-remote --get-url --symref $(TARGET_ORIGIN))
41+
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)
42+
endif
3243

3344

3445
##@ Pattern Common Tasks

0 commit comments

Comments
 (0)