From ee27eb328d68b5880390379e32ae5b75efeb8584 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Thu, 23 Jul 2020 21:09:31 +0000 Subject: [PATCH] Add error checking to location load in endpoints service (#3781) Signed-off-by: Modular Magician --- .changelog/3781.txt | 3 +++ google/resource_endpoints_service.go | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changelog/3781.txt diff --git a/.changelog/3781.txt b/.changelog/3781.txt new file mode 100644 index 00000000000..2d816ee1cc2 --- /dev/null +++ b/.changelog/3781.txt @@ -0,0 +1,3 @@ +```release-note:bug +endpoints: Fixed a crash when `google_endpoints_service` is used on a machine without timezone data +``` diff --git a/google/resource_endpoints_service.go b/google/resource_endpoints_service.go index 5e0a769a5bd..040a7353802 100644 --- a/google/resource_endpoints_service.go +++ b/google/resource_endpoints_service.go @@ -153,7 +153,11 @@ func predictServiceId(d *schema.ResourceDiff, meta interface{}) error { if !d.HasChange("openapi_config") && !d.HasChange("grpc_config") && !d.HasChange("protoc_output_base64") { return nil } - loc, _ := time.LoadLocation("America/Los_Angeles") + loc, err := time.LoadLocation("America/Los_Angeles") + if err != nil { + // Timezone data may not be present on some machines, in that case skip + return nil + } baseDate := time.Now().In(loc).Format("2006-01-02") oldConfigId := d.Get("config_id").(string) if match, err := regexp.MatchString(`\d\d\d\d-\d\d-\d\dr\d*`, oldConfigId); !match || err != nil {