cli: show workspace name in destroy confirmation (#18253)

* cli: show workspace name in destroy confirmation

If the workspace name is not "default", include it in the confirmation
message for `terraform destroy`.

Fixes #15480
This commit is contained in:
Kristin Laemmert 2018-06-19 13:35:28 -07:00 committed by GitHub
parent b95f74956a
commit 85be12d783
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 3 deletions

View File

@ -84,14 +84,21 @@ func (b *Local) opApply(
if mustConfirm { if mustConfirm {
var desc, query string var desc, query string
if op.Destroy { if op.Destroy {
// Default destroy message if op.Workspace != "default" {
query = "Do you really want to destroy all resources in workspace \"" + op.Workspace + "\"?"
} else {
query = "Do you really want to destroy all resources?"
}
desc = "Terraform will destroy all your managed infrastructure, as shown above.\n" + desc = "Terraform will destroy all your managed infrastructure, as shown above.\n" +
"There is no undo. Only 'yes' will be accepted to confirm." "There is no undo. Only 'yes' will be accepted to confirm."
query = "Do you really want to destroy?"
} else { } else {
if op.Workspace != "default" {
query = "Do you want to perform these actions in workspace \"" + op.Workspace + "\"?"
} else {
query = "Do you want to perform these actions?"
}
desc = "Terraform will perform the actions described above.\n" + desc = "Terraform will perform the actions described above.\n" +
"Only 'yes' will be accepted to approve." "Only 'yes' will be accepted to approve."
query = "Do you want to perform these actions?"
} }
if !trivialPlan { if !trivialPlan {