Skip to content

Commit

Permalink
cmd/gomote: use an unauthenticated LUCI client by default
Browse files Browse the repository at this point in the history
The current experience sends non-Googlers down a bunch of scary
authentication prompts asking them to give LUCI access to their GCP
information. This is completely unnecessary.

Add a flag, -public, set to true by default, which causes an
unauthenticated client to be used. The purpose of authentication is
primarily for reproducing non-public builds, though... it turns out
those aren't even supported yet by gomote. Whoops.

Change-Id: I73fb245df8b45917a405312970faf92e825ac3ba
Reviewed-on: https://go-review.googlesource.com/c/build/+/623635
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Carlos Amedee <[email protected]>
  • Loading branch information
mknyszek committed Nov 1, 2024
1 parent f0c4cf4 commit f8f181a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
5 changes: 0 additions & 5 deletions cmd/gomote/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,5 @@ func login(args []string) error {
if _, err := iapclient.TokenSourceForceLogin(ctx); err != nil {
fmt.Fprintf(os.Stderr, "unable to authenticate into gomoteserver: %s\n", err)
}
auth := createLUCIAuthenticator(ctx)
log.Print("Authenticating with the LUCI service.")
if err := auth.Login(); err != nil {
fmt.Fprintf(os.Stderr, "unable to authenticate into LUCI: %s\n", err)
}
return nil
}
28 changes: 17 additions & 11 deletions cmd/gomote/repro.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ func repro(args []string) error {
os.Exit(1)
}
var cfg createConfig
var public bool
fs.BoolVar(&cfg.printStatus, "status", true, "print regular status updates while waiting")
fs.IntVar(&cfg.count, "count", 1, "number of instances to create")
fs.StringVar(&cfg.newGroup, "new-group", "", "also create a new group and add the new instances to it")
fs.BoolVar(&public, "public", true, "whether the build you're trying to reproduce is public")
cfg.useGolangbuild = true

fs.Parse(args)
Expand All @@ -61,19 +63,23 @@ func repro(args []string) error {
if err != nil {
return fmt.Errorf("parsing build ID: %v", err)
}
// Always use a default unauthenticated client for public builds.
ctx := context.Background()
au := createLUCIAuthenticator(ctx)
if err := au.CheckLoginRequired(); errors.Is(err, auth.ErrLoginRequired) {
log.Println("LUCI login required... initiating interactive login process")
if err := au.Login(); err != nil {
return err
hc := http.DefaultClient
if !public {
au := createLUCIAuthenticator(ctx)
if err := au.CheckLoginRequired(); errors.Is(err, auth.ErrLoginRequired) {
log.Println("LUCI login required... initiating interactive login process")
if err := au.Login(); err != nil {
return err
}
} else if err != nil {
return fmt.Errorf("checking whether LUCI login is required: %w", err)
}
hc, err = au.Client()
if err != nil {
return fmt.Errorf("creating HTTP client: %w", err)
}
} else if err != nil {
return fmt.Errorf("checking whether LUCI login is required: %w", err)
}
hc, err := au.Client()
if err != nil {
return fmt.Errorf("creating HTTP client: %w", err)
}
bc := bbpb.NewBuildsPRPCClient(&prpc.Client{
C: hc,
Expand Down

0 comments on commit f8f181a

Please sign in to comment.