command/apply: -Xnew-destroy

This commit is contained in:
Mitchell Hashimoto 2016-10-22 12:36:47 -07:00
parent 5a8ec482a2
commit 1a418c1452
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
2 changed files with 21 additions and 0 deletions

View File

@ -115,6 +115,26 @@ func (c *ApplyCommand) Run(args []string) int {
}
}
// Check for the new destroy
if terraform.X_newDestroy {
desc := "Experimental new destroy graph has been enabled. This may still\n" +
"have bugs, and should be used with care. If you'd like to continue,\n" +
"you must enter exactly 'yes' as a response."
v, err := c.UIInput().Input(&terraform.InputOpts{
Id: "Xnew-destroy",
Query: "Experimental feature enabled: new destroy graph. Continue?",
Description: desc,
})
if err != nil {
c.Ui.Error(fmt.Sprintf("Error asking for confirmation: %s", err))
return 1
}
if v != "yes" {
c.Ui.Output("Apply cancelled.")
return 1
}
}
// Build the context based on the arguments given
ctx, planned, err := c.Context(contextOpts{
Destroy: c.Destroy,

View File

@ -337,6 +337,7 @@ func (m *Meta) flagSet(n string) *flag.FlagSet {
// Experimental features
f.BoolVar(&terraform.X_newApply, "Xnew-apply", false, "experiment: new apply")
f.BoolVar(&terraform.X_newDestroy, "Xnew-destroy", false, "experiment: new destroy")
// Create an io.Writer that writes to our Ui properly for errors.
// This is kind of a hack, but it does the job. Basically: create