Is git(lab) possible to provide access token without modifying the clone URL?

6/28/2021

I want to clone a repository in a helm chart like:

        - name: clone-repo
          image: alpine/git
          command: ['sh', '-c', 'cd /init-data; git clone --branch ${git_branch} ${repo_url} .; rm -rf .git; ls; chmod -R 777 /init-data']
          env:
            - name: repo_url
              value: {{ .Values.git.repoUrl }}
            - name: git_branch
              value: {{ .Values.git.branch | quote }}
            - name: git_token
              valueFrom:
                secretKeyRef:
                  name: gitlab-bot
                  key: git-token

My problem is I don't know how to pass the git_token (of GitLab) to git command. I know I can use like http://<token>@<path> format, but it requires string modification and I currently don't know how to do it in a helm chart.

Is it an argument like --username or --password for git command so I can pass the access token into?

-- Romulus Urakagi Ts&#39;ai
git
kubernetes
kubernetes-helm

0 Answers