Skip to content

Commit

Permalink
Send empty privateVisibilityConfig network array (#3865) (#7022)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Aug 13, 2020
1 parent f90c2c0 commit 9c9430f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/3865.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
dns: fixed an issue where `google_dns_managed_zone` would not remove `private_visibility_config` on updates
```
10 changes: 7 additions & 3 deletions google/resource_dns_managed_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func resourceDNSManagedZoneCreate(d *schema.ResourceData, meta interface{}) erro
privateVisibilityConfigProp, err := expandDNSManagedZonePrivateVisibilityConfig(d.Get("private_visibility_config"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("private_visibility_config"); !isEmptyValue(reflect.ValueOf(privateVisibilityConfigProp)) && (ok || !reflect.DeepEqual(v, privateVisibilityConfigProp)) {
} else if v, ok := d.GetOkExists("private_visibility_config"); ok || !reflect.DeepEqual(v, privateVisibilityConfigProp) {
obj["privateVisibilityConfig"] = privateVisibilityConfigProp
}
forwardingConfigProp, err := expandDNSManagedZoneForwardingConfig(d.Get("forwarding_config"), d, config)
Expand Down Expand Up @@ -472,7 +472,7 @@ func resourceDNSManagedZoneUpdate(d *schema.ResourceData, meta interface{}) erro
privateVisibilityConfigProp, err := expandDNSManagedZonePrivateVisibilityConfig(d.Get("private_visibility_config"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("private_visibility_config"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, privateVisibilityConfigProp)) {
} else if v, ok := d.GetOkExists("private_visibility_config"); ok || !reflect.DeepEqual(v, privateVisibilityConfigProp) {
obj["privateVisibilityConfig"] = privateVisibilityConfigProp
}
forwardingConfigProp, err := expandDNSManagedZoneForwardingConfig(d.Get("forwarding_config"), d, config)
Expand Down Expand Up @@ -924,7 +924,11 @@ func expandDNSManagedZoneVisibility(v interface{}, d TerraformResourceData, conf
func expandDNSManagedZonePrivateVisibilityConfig(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
return nil, nil
// The API won't remove the the field unless an empty network array is sent.
transformed := make(map[string]interface{})
emptyNetwork := make([]interface{}, 0)
transformed["networks"] = emptyNetwork
return transformed, nil
}
raw := l[0]
original := raw.(map[string]interface{})
Expand Down

0 comments on commit 9c9430f

Please sign in to comment.