Skip to content

Commit

Permalink
Don't include size if database is already bigger
Browse files Browse the repository at this point in the history
  • Loading branch information
gh-mlfowler committed Jan 13, 2017
1 parent 2fe47f4 commit abb2e3d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions resource_sql_database_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{})
}

if v, ok := _settings["disk_size"]; ok {
if v.(int) > 0 {
if v.(int) > 0 && int64(v.(int)) > instance.Settings.DataDiskSizeGb {
settings.DataDiskSizeGb = int64(v.(int))
}
}
Expand Down Expand Up @@ -992,6 +992,7 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{})
if vp != nil {
_authorizedNetworksList = vp.([]interface{})
}

_oipc_map := make(map[string]interface{})
for _, _ipc := range _oldAuthorizedNetworkList {
_oipc_map[_ipc.(string)] = true
Expand All @@ -1005,8 +1006,7 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{})
settings.IpConfiguration.AuthorizedNetworks, entry)
}
}
// finally, update old entries and insert new ones
// and are still defined.
// insert new ones
for _, _ipc := range _authorizedNetworksList {
entry := &sqladmin.AclEntry{}
entry.Value = _ipc.(string)
Expand Down Expand Up @@ -1052,7 +1052,8 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{})

op, err := config.clientSqlAdmin.Instances.Update(project, instance.Name, instance).Do()
if err != nil {
return fmt.Errorf("Error, failed to update instance %s: %s", instance.Name, err)
json, _ := instance.MarshalJSON()
return fmt.Errorf("Error, failed to update instance %s: %s, %v", instance.Name, err, string(json[:]))
}

err = sqladminOperationWait(config, op, "Create Instance")
Expand Down

0 comments on commit abb2e3d

Please sign in to comment.