Skip to content

Commit

Permalink
cmd/cueckoo: start using basic auth for gerrit as well
Browse files Browse the repository at this point in the history
Just like we do with GitHub via git's credentials,
so that runtrybot can work on CLs on private repositores.

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: Ia9ba8d90348fde2b646e21f31dc252540928d3b1
Dispatch-Trailer: {"type":"trybot","CL":557240,"patchset":1,"ref":"refs/changes/40/557240/1","targetBranch":"master"}
  • Loading branch information
mvdan authored and cueckoo committed Aug 3, 2023
1 parent c35c713 commit c8bb7b6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/cueckoo/cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,20 @@ func loadConfig(ctx context.Context) (*config, error) {
githubAuth := github.BasicAuthTransport{Username: githubUser, Password: githubPassword}
res.githubClient = github.NewClient(githubAuth.Client())

gerritUser, gerritPassword, err := gitCredentials(ctx, gerritURL)
if gerritUser == "" || gerritPassword == "" || err != nil {
// Fall back to the manual env vars.
gerritUser = os.Getenv("GERRIT_USER")
gerritPassword = os.Getenv("GERRIT_PASSWORD")
if gerritUser == "" || gerritPassword == "" {
return nil, fmt.Errorf("configure a git credential helper or set GERRIT_USER and GERRIT_PASSWORD")
}
}
res.gerritClient, err = gerrit.NewClient(res.gerritURL, nil)
if err != nil {
return nil, err
}
res.gerritClient.Authentication.SetBasicAuth(gerritUser, gerritPassword)

return &res, nil
}
Expand Down

0 comments on commit c8bb7b6

Please sign in to comment.