providers/heroku: nuking config vars works
This commit is contained in:
parent
557d63dde6
commit
2a6b83591a
|
@ -12,6 +12,8 @@ BACKWARDS INCOMPATIBILITIES:
|
||||||
BUG FIXES:
|
BUG FIXES:
|
||||||
|
|
||||||
* core: Variables are validated to not contain interpolations. [GH-180]
|
* core: Variables are validated to not contain interpolations. [GH-180]
|
||||||
|
* providers/heroku: If you delete the `config_vars` block, config vars
|
||||||
|
are properly nuked.
|
||||||
|
|
||||||
PLUGIN CHANGES:
|
PLUGIN CHANGES:
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ func resourceHerokuAppCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
log.Printf("[INFO] App ID: %s", d.Id())
|
log.Printf("[INFO] App ID: %s", d.Id())
|
||||||
|
|
||||||
if v := d.Get("config_vars"); v != nil {
|
if v := d.Get("config_vars"); v != nil {
|
||||||
err = update_config_vars(d.Id(), v.([]interface{}), client)
|
err = update_config_vars(d.Id(), client, nil, v.([]interface{}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -175,16 +175,21 @@ func resourceHerokuAppUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
d.SetId(renamedApp.Name)
|
d.SetId(renamedApp.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the config vars. If we have none, then set it to the empty
|
// If the config vars changed, then recalculate those
|
||||||
// list so that they're properly removed.
|
if d.HasChange("config_vars") {
|
||||||
v := d.Get("config_vars")
|
o, n := d.GetChange("config_vars")
|
||||||
if v == nil {
|
if o == nil {
|
||||||
v = []interface{}{}
|
o = []interface{}{}
|
||||||
}
|
}
|
||||||
|
if n == nil {
|
||||||
|
n = []interface{}{}
|
||||||
|
}
|
||||||
|
|
||||||
err := update_config_vars(d.Id(), v.([]interface{}), client)
|
err := update_config_vars(
|
||||||
if err != nil {
|
d.Id(), client, o.([]interface{}), n.([]interface{}))
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return resourceHerokuAppRead(d, meta)
|
return resourceHerokuAppRead(d, meta)
|
||||||
|
@ -226,10 +231,19 @@ func retrieve_config_vars(id string, client *heroku.Client) (map[string]string,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updates the config vars for from an expanded configuration.
|
// Updates the config vars for from an expanded configuration.
|
||||||
func update_config_vars(id string, vs []interface{}, client *heroku.Client) error {
|
func update_config_vars(
|
||||||
|
id string,
|
||||||
|
client *heroku.Client,
|
||||||
|
o []interface{},
|
||||||
|
n []interface{}) error {
|
||||||
vars := make(map[string]*string)
|
vars := make(map[string]*string)
|
||||||
|
|
||||||
for _, v := range vs {
|
for _, v := range o {
|
||||||
|
for k, _ := range v.(map[string]interface{}) {
|
||||||
|
vars[k] = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, v := range n {
|
||||||
for k, v := range v.(map[string]interface{}) {
|
for k, v := range v.(map[string]interface{}) {
|
||||||
val := v.(string)
|
val := v.(string)
|
||||||
vars[k] = &val
|
vars[k] = &val
|
||||||
|
|
Loading…
Reference in New Issue