terraform: diff is not empty if it has to destroy
This commit is contained in:
parent
1d9d33c8a0
commit
4147500fcc
|
@ -76,7 +76,7 @@ func (d *Diff) Empty() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, rd := range d.Resources {
|
for _, rd := range d.Resources {
|
||||||
if len(rd.Attributes) > 0 {
|
if !rd.Empty() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,9 +228,13 @@ func (t *Terraform) planWalkFn(
|
||||||
var diff *ResourceDiff
|
var diff *ResourceDiff
|
||||||
|
|
||||||
if r.Config == nil {
|
if r.Config == nil {
|
||||||
|
log.Printf("[DEBUG] %s: Orphan, marking for destroy", r.Id)
|
||||||
|
|
||||||
// This is an orphan (no config), so we mark it to be destroyed
|
// This is an orphan (no config), so we mark it to be destroyed
|
||||||
diff = &ResourceDiff{Destroy: true}
|
diff = &ResourceDiff{Destroy: true}
|
||||||
} else {
|
} else {
|
||||||
|
log.Printf("[DEBUG] %s: Executing diff", r.Id)
|
||||||
|
|
||||||
// Get a diff from the newest state
|
// Get a diff from the newest state
|
||||||
var err error
|
var err error
|
||||||
diff, err = r.Provider.Diff(r.State, r.Config)
|
diff, err = r.Provider.Diff(r.State, r.Config)
|
||||||
|
@ -312,15 +316,20 @@ func (t *Terraform) genericWalkFn(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure that at least some resource configuration is set
|
// Make sure that at least some resource configuration is set
|
||||||
if rn.Resource.Config == nil && !rn.Orphan {
|
if !rn.Orphan {
|
||||||
|
if rn.Resource.Config == nil {
|
||||||
if rn.Config == nil {
|
if rn.Config == nil {
|
||||||
rn.Resource.Config = new(ResourceConfig)
|
rn.Resource.Config = new(ResourceConfig)
|
||||||
} else {
|
} else {
|
||||||
rn.Resource.Config = NewResourceConfig(rn.Config.RawConfig)
|
rn.Resource.Config = NewResourceConfig(rn.Config.RawConfig)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
rn.Resource.Config = nil
|
||||||
|
}
|
||||||
|
|
||||||
// Call the callack
|
// Call the callack
|
||||||
|
log.Printf("Walking: %s", rn.Resource.Id)
|
||||||
newVars, err := cb(rn.Resource)
|
newVars, err := cb(rn.Resource)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue