cmd/teeproxy: use default client if GCP credentials not found
Use default client for teeproxy requests if the project GCP credentials
are not found. This allows anyone to run the teeproxy locally.
@@ -43,7 +43,7 @@ func main() {
log.Fatal(ctx, err)
}
}
- var client *http.Client
+ client := &http.Client{}
var jsonCreds []byte
if *credsFile != "" {
jsonCreds, err = ioutil.ReadFile(*credsFile)
@@ -55,14 +55,18 @@ func main() {
log.Infof(ctx, "getting secret %q", secretName)
s, err := secrets.Get(context.Background(), secretName)
if err != nil {
- log.Fatal(ctx, err)
- }
+ log.Infof(ctx, "secret %q not found", secretName)
+ } else {
jsonCreds = []byte(s)
}
+ }
+
+ if jsonCreds != nil {
client, err = auth.NewClient(jsonCreds)
if err != nil {
log.Fatal(ctx, err)
}
+ }
views := append(dcensus.ServerViews,
teeproxy.TeeproxyGddoRequestCount,
