Skip to content

Commit 433076b

Browse files
dmitshurgopherbot
authored andcommitted
cmd/bootstrapswarm: default token file path to LUCI_MACHINE_TOKEN
If LUCI_MACHINE_TOKEN is set in the environment (intended for the swarming bot; added in crrev.com/i/6478812), also recognize it here and use it as the default token file path flag value. Change-Id: Iee2fa48e7b9c3a57b50afeeee458d18136df9243 Reviewed-on: https://go-review.googlesource.com/c/build/+/530475 Reviewed-by: Carlos Amedee <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]>
1 parent 0166ca5 commit 433076b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

cmd/bootstrapswarm/bootstrapswarm.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
// Requirements:
2222
// - Python3 installed and in the calling user's PATH.
2323
// - luci_machine_tokend running as root in a cron job.
24-
// https://chromium.googlesource.com/infra/luci/luci-go/+/refs/heads/main/tokenserver
25-
// Further instructions can be found at https://github.com/golang/go/wiki/DashboardBuilders
24+
// See https://chromium.googlesource.com/infra/luci/luci-go/+/main/tokenserver.
25+
// Further instructions can be found at https://go.dev/wiki/DashboardBuilders.
2626
// The default locations for the token files should be used if possible:
2727
// Most OS: /var/lib/luci_machine_tokend/token.json
2828
// Windows: C:\luci_machine_tokend\token.json
29+
// A custom default location can be set via the environment variable LUCI_MACHINE_TOKEN.
2930
// - bootstrapswarm should not be run as a privileged user.
3031
package main
3132

@@ -186,9 +187,11 @@ func retrieveGCEVMToken(ctx context.Context) (string, error) {
186187
}
187188

188189
func defaultTokenLocation() string {
189-
out := "/var/lib/luci_machine_tokend/token.json"
190+
if v := os.Getenv("LUCI_MACHINE_TOKEN"); v != "" {
191+
return v
192+
}
190193
if runtime.GOOS == "windows" {
191194
return `C:\luci_machine_tokend\token.json`
192195
}
193-
return out
196+
return "/var/lib/luci_machine_tokend/token.json"
194197
}

0 commit comments

Comments
 (0)