Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error checking to location load in endpoints service #6849

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3781.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
endpoints: Fixed a crash when `google_endpoints_service` is used on a machine without timezone data
```
6 changes: 5 additions & 1 deletion google/resource_endpoints_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down