Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Unified Diff: client/cmd/buildbucket/base_command.go

Issue 2104013002: buildbucket: use OptionalLogin if service account is not passed (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/cmd/buildbucket/base_command.go
diff --git a/client/cmd/buildbucket/base_command.go b/client/cmd/buildbucket/base_command.go
index 31e26e507911071e74a56c006980f570cd9091e2..856e257752a6e7aace95b516cfa5e1150f3dfe89 100644
--- a/client/cmd/buildbucket/base_command.go
+++ b/client/cmd/buildbucket/base_command.go
@@ -36,7 +36,14 @@ func (r *baseCommandRun) makeService(ctx context.Context, a subcommands.Applicat
if r.host == "" {
return nil, errors.New("a host for the buildbucket service must be provided")
}
- authenticator := auth.NewAuthenticator(ctx, auth.SilentLogin, auth.Options{ServiceAccountJSONPath: r.serviceAccountJSONPath})
+
+ loginMode := auth.OptionalLogin
+ if r.serviceAccountJSONPath != "" {
+ // if service account is specified, the request MUST be authenticated
+ // otherwise it is optional.
+ loginMode = auth.SilentLogin
+ }
+ authenticator := auth.NewAuthenticator(ctx, loginMode, auth.Options{ServiceAccountJSONPath: r.serviceAccountJSONPath})
client, err := authenticator.Client()
if err != nil {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698