2023-04-06 10:54:58 +00:00
|
|
|
package phases
|
|
|
|
|
|
|
|
import (
|
2023-05-16 16:35:39 +00:00
|
|
|
"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"
|
2023-04-06 10:54:58 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// The destroy phase deletes artifacts and resources.
|
|
|
|
func Destroy() bundle.Mutator {
|
2023-05-24 12:45:19 +00:00
|
|
|
|
|
|
|
destroyMutator := bundle.Seq(
|
2023-05-16 16:01:50 +00:00
|
|
|
lock.Acquire(),
|
2023-05-24 12:45:19 +00:00
|
|
|
bundle.Defer(
|
|
|
|
bundle.Seq(
|
|
|
|
terraform.StatePull(),
|
|
|
|
terraform.Plan(terraform.PlanGoal("destroy")),
|
|
|
|
terraform.Destroy(),
|
|
|
|
terraform.StatePush(),
|
|
|
|
files.Delete(),
|
|
|
|
),
|
|
|
|
lock.Release(),
|
|
|
|
),
|
|
|
|
)
|
2023-05-16 16:01:50 +00:00
|
|
|
|
2023-04-06 10:54:58 +00:00
|
|
|
return newPhase(
|
|
|
|
"destroy",
|
2023-05-24 12:45:19 +00:00
|
|
|
[]bundle.Mutator{destroyMutator},
|
2023-04-06 10:54:58 +00:00
|
|
|
)
|
|
|
|
}
|