From 00dfa68b2b97705e8c47c21a2eb6f6859c405e5d Mon Sep 17 00:00:00 2001
From: "roi.kramer" <roi.kramer@codefresh.io>
Date: Thu, 28 Apr 2022 14:54:21 +0300
Subject: [PATCH] add repo path to installer

---
 installer/helm/Chart.yaml                   | 4 ++--
 installer/helm/templates/installer/job.yaml | 6 +++++-
 installer/helm/values.yaml                  | 2 ++
 installer/install.sh                        | 4 +++-
 4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/installer/helm/Chart.yaml b/installer/helm/Chart.yaml
index e371c75..26d2a5b 100644
--- a/installer/helm/Chart.yaml
+++ b/installer/helm/Chart.yaml
@@ -2,5 +2,5 @@ apiVersion: v2
 name: csdp-installer
 description: A Helm chart used for installing a CSDP runtime
 type: application
-version: 0.1.11
-appVersion: v0.0.5
+version: 0.1.12
+appVersion: v0.0.6
diff --git a/installer/helm/templates/installer/job.yaml b/installer/helm/templates/installer/job.yaml
index 1340cdb..1915908 100644
--- a/installer/helm/templates/installer/job.yaml
+++ b/installer/helm/templates/installer/job.yaml
@@ -37,7 +37,11 @@ spec:
             - name: CSDP_RUNTIME_NAME
               value: {{ .Values.csdpInstaller.runtime.name | quote }}
             - name: CSDP_RUNTIME_REPO
-              value: {{ .Values.csdpInstaller.runtime.repo | quote }}
+              value: {{ .Values.csdpInstaller.runtime.repoURL }}
+            {{- if .Values.csdpInstaller.runtime.repoPath }}
+            - name: CSDP_RUNTIME_REPO_PATH
+              value: {{ .Values.csdpInstaller.runtime.repoPath }}
+            {{- end }}
             - name: CSDP_RUNTIME_GIT_TOKEN
               valueFrom:
                 secretKeyRef:
diff --git a/installer/helm/values.yaml b/installer/helm/values.yaml
index 8035d17..bb1628d 100644
--- a/installer/helm/values.yaml
+++ b/installer/helm/values.yaml
@@ -25,6 +25,8 @@ csdpInstaller:
     name: some-runtime
     # CSDP runtime installation repo url
     repoURL: https://github.com/some/user-repo
+    # CSDP runtime installation repo path to the bootstrap directory
+    repoPath: ""
     # Git authentication token
     gitToken:
       secretKeyRef:
diff --git a/installer/install.sh b/installer/install.sh
index 54f72c4..c4662f7 100755
--- a/installer/install.sh
+++ b/installer/install.sh
@@ -38,6 +38,7 @@ CSDP_RUNTIME_VERSION="${CSDP_RUNTIME_VERSION:-latest}"
 CSDP_GIT_INTEGRATION_PROVIDER="${CSDP_GIT_INTEGRATION_PROVIDER:-GITHUB}"
 CSDP_GIT_INTEGRATION_API_URL="${CSDP_GIT_INTEGRATION_API_URL:-https://api.github.com}"
 CSDP_GIT_INTEGRATION_TOKEN="${CSDP_GIT_INTEGRATION_TOKEN:-${CSDP_RUNTIME_GIT_TOKEN}}"
+CSDP_RUNTIME_REPO_PATH="${CSDP_RUNTIME_REPO_PATH:-runtimes/${CSDP_RUNTIME_NAME}/bootstrap}"
 CSDP_RUNTIME_REPO_CREDS_PATTERN=`echo ${CSDP_RUNTIME_REPO} | grep --color=never -E -o '^http[s]?:\/\/([a-zA-Z0-9\.]*)'`
 CSDP_MANAGED_RUNTIME="${CSDP_MANAGED_RUNTIME:-false}"
 
@@ -146,7 +147,7 @@ create_bootstrap_application() {
               jsonPointers:
                 - /status
         source:
-            path: base/bootstrap
+            path: ${CSDP_RUNTIME_REPO_PATH}
             repoURL: ${CSDP_RUNTIME_REPO}
             targetRevision: HEAD
         syncPolicy:
@@ -290,6 +291,7 @@ echo "  namespace: ${NAMESPACE}"
 echo "  csdp url: ${CSDP_URL}"
 echo "  csdp token: ****"
 echo "  runtime repo: ${CSDP_RUNTIME_REPO}"
+echo "  runtime repo path: ${CSDP_RUNTIME_REPO_PATH}"
 echo "  runtime repo creds pattern: ${CSDP_RUNTIME_REPO_CREDS_PATTERN}"
 echo "  runtime git-token: ****"
 echo "  runtime cluster: ${CSDP_RUNTIME_CLUSTER}"