Skip to content

Commit d9085fe

Browse files
jolheiserzeripath
andauthored
Fix anonymous GL migration (#12862)
* 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>
1 parent 0d14c2f commit d9085fe

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

modules/migrations/gitlab.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ type GitlabDownloader struct {
7676
func NewGitlabDownloader(ctx context.Context, baseURL, repoPath, username, password, token string) (*GitlabDownloader, error) {
7777
var gitlabClient *gitlab.Client
7878
var err error
79-
if token != "" {
80-
gitlabClient, err = gitlab.NewClient(token, gitlab.WithBaseURL(baseURL))
81-
} else {
79+
gitlabClient, err = gitlab.NewClient(token, gitlab.WithBaseURL(baseURL))
80+
// Only use basic auth if token is blank and password is NOT
81+
// Basic auth will fail with empty strings, but empty token will allow anonymous public API usage
82+
if token == "" && password != "" {
8283
gitlabClient, err = gitlab.NewBasicAuthClient(username, password, gitlab.WithBaseURL(baseURL))
8384
}
8485

0 commit comments

Comments
 (0)