github.com/databricks/cli@v0.203.0/bundle/phases/destroy.go (about)

     1  package phases
     2  
     3  import (
     4  	"github.com/databricks/cli/bundle"
     5  	"github.com/databricks/cli/bundle/deploy/files"
     6  	"github.com/databricks/cli/bundle/deploy/lock"
     7  	"github.com/databricks/cli/bundle/deploy/terraform"
     8  )
     9  
    10  // The destroy phase deletes artifacts and resources.
    11  func Destroy() bundle.Mutator {
    12  
    13  	destroyMutator := bundle.Seq(
    14  		lock.Acquire(),
    15  		bundle.Defer(
    16  			bundle.Seq(
    17  				terraform.Interpolate(),
    18  				terraform.Write(),
    19  				terraform.StatePull(),
    20  				terraform.Plan(terraform.PlanGoal("destroy")),
    21  				terraform.Destroy(),
    22  				terraform.StatePush(),
    23  				files.Delete(),
    24  			),
    25  			lock.Release(lock.GoalDestroy),
    26  		),
    27  	)
    28  
    29  	return newPhase(
    30  		"destroy",
    31  		[]bundle.Mutator{destroyMutator},
    32  	)
    33  }