diff --git a/plans/changes_sync.go b/plans/changes_sync.go index 615f85392..5e735c09a 100644 --- a/plans/changes_sync.go +++ b/plans/changes_sync.go @@ -21,6 +21,24 @@ type ChangesSync struct { changes *Changes } +// FullDestroy returns true if the set of changes indicates we are doing a +// destroy of all resources. +func (cs *ChangesSync) FullDestroy() bool { + if cs == nil { + panic("FullDestroy on nil ChangesSync") + } + cs.lock.Lock() + defer cs.lock.Unlock() + + for _, c := range cs.changes.Resources { + if c.Action != Delete { + return false + } + } + + return true +} + // AppendResourceInstanceChange records the given resource instance change in // the set of planned resource changes. //