From cb591ab2df839b2f4dda62fba73442aeb0a0bcf5 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 24 Jun 2014 12:55:59 -0700 Subject: [PATCH] helper/resource: Destroy is called if destroy is set on diff --- helper/resource/map.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/helper/resource/map.go b/helper/resource/map.go index 07eaa4310..ea1860e48 100644 --- a/helper/resource/map.go +++ b/helper/resource/map.go @@ -23,6 +23,21 @@ func (m *Map) Apply( return nil, fmt.Errorf("Unknown resource type: %s", s.Type) } + if d.Destroy { + // If we're destroying a resource that doesn't exist, then we're + // already done. + if s.ID == "" { + return nil, nil + } + + // Otherwise call the destroy function + err := r.Destroy(s, meta) + if err == nil { + s = nil + } + return s, err + } + if s.ID == "" { return r.Create(s, d, meta) } else {