Skip to content

Commit

Permalink
Fix anonymous GL migration (#12862)
Browse files Browse the repository at this point in the history
* Fix anonymous GL migration

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Rely on password instead

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: zeripath <art27@cantab.net>
  • Loading branch information
jolheiser and zeripath authored Sep 15, 2020
1 parent 0d14c2f commit d9085fe
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions modules/migrations/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ type GitlabDownloader struct {
func NewGitlabDownloader(ctx context.Context, baseURL, repoPath, username, password, token string) (*GitlabDownloader, error) {
var gitlabClient *gitlab.Client
var err error
if token != "" {
gitlabClient, err = gitlab.NewClient(token, gitlab.WithBaseURL(baseURL))
} else {
gitlabClient, err = gitlab.NewClient(token, gitlab.WithBaseURL(baseURL))
// Only use basic auth if token is blank and password is NOT
// Basic auth will fail with empty strings, but empty token will allow anonymous public API usage
if token == "" && password != "" {
gitlabClient, err = gitlab.NewBasicAuthClient(username, password, gitlab.WithBaseURL(baseURL))
}

Expand Down

0 comments on commit d9085fe

Please sign in to comment.