databricks-cli/bundle/phases/destroy.go

32 lines
653 B
Go
Raw Normal View History

package phases
import (
"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/deploy/files"
"github.com/databricks/cli/bundle/deploy/lock"
"github.com/databricks/cli/bundle/deploy/terraform"
)
// The destroy phase deletes artifacts and resources.
func Destroy() bundle.Mutator {
destroyMutator := bundle.Seq(
2023-05-16 16:01:50 +00:00
lock.Acquire(),
bundle.Defer(
bundle.Seq(
terraform.StatePull(),
terraform.Plan(terraform.PlanGoal("destroy")),
terraform.Destroy(),
terraform.StatePush(),
files.Delete(),
),
lock.Release(lock.GoalDestroy),
),
)
2023-05-16 16:01:50 +00:00
return newPhase(
"destroy",
[]bundle.Mutator{destroyMutator},
)
}