mirror of
https://github.com/golang/go
synced 2024-11-18 16:44:43 -07:00
dashboard/buildlet: fix start-up crash when TLS attributes aren't set
I had never run the 44d7ecb402
on GCE, and never caught that it
crashed on start-up if TLS attributes weren't defined.
Updated to use the new NotDefinedError from the metadata package in
https://code-review.googlesource.com/#/c/1790/
Change-Id: Iaec8df126e4cef8026c930e8cc0163ae088affb3
Reviewed-on: https://go-review.googlesource.com/2736
Reviewed-by: Burcu Dogan <jbd@google.com>
This commit is contained in:
parent
ac8637e9fa
commit
c573f9d0b5
@ -119,6 +119,7 @@ func main() {
|
||||
}
|
||||
|
||||
// metadataValue returns the GCE metadata instance value for the given key.
|
||||
// If the metadata is not defined, the returned string is empty.
|
||||
//
|
||||
// If not running on GCE, it falls back to using environment variables
|
||||
// for local development.
|
||||
@ -126,6 +127,9 @@ func metadataValue(key string) string {
|
||||
// The common case:
|
||||
if metadata.OnGCE() {
|
||||
v, err := metadata.InstanceAttributeValue(key)
|
||||
if _, notDefined := err.(metadata.NotDefinedError); notDefined {
|
||||
return ""
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatalf("metadata.InstanceAttributeValue(%q): %v", key, err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user