Skip to content

Commit

Permalink
[THOG-204] Use oauth2 as username when cloning (#441)
Browse files Browse the repository at this point in the history
* Use oauth2 as the username for cloning private repos with a token.

* Update username string.

* Only set user to "placeholder" if no username is present.
  • Loading branch information
ahrav authored and bill-rich committed May 2, 2022
1 parent dc87135 commit e2b2a90
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/sources/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,13 @@ func (s *Source) scanRepos(ctx context.Context, chunksChan chan *sources.Chunk,
}
s.SetProgressComplete(i, len(repos), fmt.Sprintf("Repo: %s", repoURL), "")

path, repo, err := git.CloneRepoUsingToken(s.token, repoURL.String(), s.user)
// If a username is not provided we need to use a default one in order to clone a private repo.
// Not setting "placeholder" as s.user on purpose in case any downstream services rely on a "" value for s.user.
user := s.user
if user == "" {
user = "placeholder"
}
path, repo, err := git.CloneRepoUsingToken(s.token, repoURL.String(), user)
defer os.RemoveAll(path)
if err != nil {
errsMut.Lock()
Expand Down

0 comments on commit e2b2a90

Please sign in to comment.