Skip to content

Commit e74cbe1

Browse files
Add error checking to location load in endpoints service (#3781) (#2302)
Signed-off-by: Modular Magician <[email protected]>
1 parent fafefe5 commit e74cbe1

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.changelog/3781.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
endpoints: Fixed a crash when `google_endpoints_service` is used on a machine without timezone data
3+
```

google-beta/resource_endpoints_service.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,11 @@ func predictServiceId(d *schema.ResourceDiff, meta interface{}) error {
153153
if !d.HasChange("openapi_config") && !d.HasChange("grpc_config") && !d.HasChange("protoc_output_base64") {
154154
return nil
155155
}
156-
loc, _ := time.LoadLocation("America/Los_Angeles")
156+
loc, err := time.LoadLocation("America/Los_Angeles")
157+
if err != nil {
158+
// Timezone data may not be present on some machines, in that case skip
159+
return nil
160+
}
157161
baseDate := time.Now().In(loc).Format("2006-01-02")
158162
oldConfigId := d.Get("config_id").(string)
159163
if match, err := regexp.MatchString(`\d\d\d\d-\d\d-\d\dr\d*`, oldConfigId); !match || err != nil {

0 commit comments

Comments
 (0)