Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change -force to -auto-approve when destroying #17218

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/local/backend_apply.go
Expand Up @@ -99,7 +99,7 @@ func (b *Local) opApply(
dispPlan := format.NewPlan(plan)
trivialPlan := dispPlan.Empty()
hasUI := op.UIOut != nil && op.UIIn != nil
mustConfirm := hasUI && ((op.Destroy && !op.DestroyForce) || (!op.Destroy && !op.AutoApprove && !trivialPlan))
mustConfirm := hasUI && ((op.Destroy && (!op.DestroyForce && !op.AutoApprove)) || (!op.Destroy && !op.AutoApprove && !trivialPlan))
if mustConfirm {
var desc, query string
if op.Destroy {
Expand Down
12 changes: 5 additions & 7 deletions command/apply.go
Expand Up @@ -40,13 +40,11 @@ func (c *ApplyCommand) Run(args []string) int {
}

cmdFlags := c.Meta.flagSet(cmdName)
cmdFlags.BoolVar(&autoApprove, "auto-approve", false, "skip interactive approval of plan before applying")
if c.Destroy {
cmdFlags.BoolVar(&destroyForce, "force", false, "force")
cmdFlags.BoolVar(&destroyForce, "force", false, "deprecated: same as auto-approve")
}
cmdFlags.BoolVar(&refresh, "refresh", true, "refresh")
if !c.Destroy {
cmdFlags.BoolVar(&autoApprove, "auto-approve", false, "skip interactive approval of plan before applying")
}
cmdFlags.IntVar(
&c.Meta.parallelism, "parallelism", DefaultParallelism, "parallelism")
cmdFlags.StringVar(&c.Meta.statePath, "state", "", "path")
Expand Down Expand Up @@ -250,8 +248,6 @@ Options:

-lock-timeout=0s Duration to retry a state lock.

-auto-approve Skip interactive approval of plan before applying.

-input=true Ask for input for variables if not directly set.

-no-color If specified, output won't contain any color.
Expand Down Expand Up @@ -297,7 +293,9 @@ Options:
modifying. Defaults to the "-state-out" path with
".backup" extension. Set to "-" to disable backup.

-force Don't ask for input for destroy confirmation.
-auto-approve Skip interactive approval before destroying.

-force Deprecated: same as auto-approve.

-lock=true Lock the state file when locking is supported.

Expand Down
6 changes: 3 additions & 3 deletions command/apply_destroy_test.go
Expand Up @@ -40,7 +40,7 @@ func TestApply_destroy(t *testing.T) {

// Run the apply command pointing to our existing state
args := []string{
"-force",
"-auto-approve",
"-state", statePath,
testFixturePath("apply"),
}
Expand Down Expand Up @@ -130,7 +130,7 @@ func TestApply_destroyLockedState(t *testing.T) {

// Run the apply command pointing to our existing state
args := []string{
"-force",
"-auto-approve",
"-state", statePath,
testFixturePath("apply"),
}
Expand Down Expand Up @@ -206,7 +206,7 @@ func TestApply_destroyTargeted(t *testing.T) {

// Run the apply command pointing to our existing state
args := []string{
"-force",
"-auto-approve",
"-target", "test_instance.foo",
"-state", statePath,
testFixturePath("apply-destroy-targeted"),
Expand Down
2 changes: 1 addition & 1 deletion command/e2etest/primary_test.go
Expand Up @@ -111,7 +111,7 @@ func TestPrimarySeparatePlan(t *testing.T) {
}

//// DESTROY
stdout, stderr, err = tf.Run("destroy", "-force")
stdout, stderr, err = tf.Run("destroy", "-auto-approve")
if err != nil {
t.Fatalf("unexpected destroy error: %s\nstderr:\n%s", err, stderr)
}
Expand Down
2 changes: 1 addition & 1 deletion website/docs/commands/destroy.html.markdown
Expand Up @@ -22,7 +22,7 @@ This command accepts all the arguments and flags that the [apply
command](/docs/commands/apply.html) accepts, with the exception of a plan file
argument.

If `-force` is set, then the destroy confirmation will not be shown.
If `-auto-approve` is set, then the destroy confirmation will not be shown.

The `-target` flag, instead of affecting "dependencies" will instead also
destroy any resources that _depend on_ the target(s) specified.
Expand Down