From 106aaadb768ce71a222c22d6007bc58150aec740 Mon Sep 17 00:00:00 2001 From: Jonathan Ingram Date: Tue, 20 Sep 2022 17:44:59 +1000 Subject: [PATCH] docd: fallback to AppEngine env vars when flags not provided (#128) --- docd/main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docd/main.go b/docd/main.go index 0d035e8..6317adc 100644 --- a/docd/main.go +++ b/docd/main.go @@ -6,6 +6,7 @@ import ( "fmt" "log" "net/http" + "os" "cloud.google.com/go/errorreporting" @@ -40,6 +41,12 @@ func main() { var er internal.ErrorReporter = &internal.NopErrorReporter{} if *errorReporting { + if *errorReportingGCPProjectID == "" { + *errorReportingGCPProjectID = os.Getenv("GOOGLE_CLOUD_PROJECT") + } + if *errorReportingAppEngineService == "" { + *errorReportingAppEngineService = os.Getenv("GAE_SERVICE") + } var err error er, err = errorreporting.NewClient(context.Background(), *errorReportingGCPProjectID, errorreporting.Config{ ServiceName: *errorReportingAppEngineService,