Fixed region_backend_service to calc hash using relative path (#1491)

Along the change on region_backend_service.backend[].group to use DiffSuppressFunc (#1487), we also need to change hash function, as [pointed out](https://github.com/terraform-providers/terraform-provider-google/pull/1487#issuecomment-389000239).

Fixed this in a same way regular backend services do.
https://github.com/terraform-providers/terraform-provider-google/blob/v1.12.0/google/resource_compute_backend_service_migrate.go#L102-L103
This commit is contained in:
Shinichi TAMURA 2018-05-23 05:05:38 +09:00 committed by Dana Hoffman
parent 0f2f6a194e
commit 028ec27ccf
2 changed files with 12 additions and 3 deletions

View File

@ -99,8 +99,12 @@ func resourceGoogleComputeBackendServiceBackendHash(v interface{}) int {
var buf bytes.Buffer
m := v.(map[string]interface{})
group, _ := getRelativePath(m["group"].(string))
buf.WriteString(fmt.Sprintf("%s-", group))
if group, err := getRelativePath(m["group"].(string)); err != nil {
log.Printf("[WARN] Error on retrieving relative path of instance group: %s", err)
buf.WriteString(fmt.Sprintf("%s-", m["group"].(string)))
} else {
buf.WriteString(fmt.Sprintf("%s-", group))
}
if v, ok := m["balancing_mode"]; ok {
buf.WriteString(fmt.Sprintf("%s-", v.(string)))

View File

@ -331,7 +331,12 @@ func resourceGoogleComputeRegionBackendServiceBackendHash(v interface{}) int {
var buf bytes.Buffer
m := v.(map[string]interface{})
buf.WriteString(fmt.Sprintf("%s-", m["group"].(string)))
if group, err := getRelativePath(m["group"].(string)); err != nil {
log.Printf("[WARN] Error on retrieving relative path of instance group: %s", err)
buf.WriteString(fmt.Sprintf("%s-", m["group"].(string)))
} else {
buf.WriteString(fmt.Sprintf("%s-", group))
}
if v, ok := m["description"]; ok {
buf.WriteString(fmt.Sprintf("%s-", v.(string)))