зеркало из https://github.com/golang/build.git
cmd/gomote: use an unauthenticated LUCI client by default
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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
This commit is contained in:
Родитель
f0c4cf42a1
Коммит
f8f181a3ab
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
@ -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,
|
||||
|
|
Загрузка…
Ссылка в новой задаче