Skip to content

Commit

Permalink
feat --everything is the default behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
haitham911 committed Dec 19, 2024
1 parent 6832ddd commit 0c90df5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/exec/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func processHelp(
" - generated 'backend.tf.json' file\n" +
" - 'terraform.tfstate.d' folder (if '--everything' flag is used)\n\n" +
"Usage: atmos terraform clean <component> -s <stack> <flags>\n\n" +
"Use '--everything' flag to also delete the Terraform state files and and directories with confirm message.\n\n" +
"Use '--everything' flag —everything is the default behavior to delete the Terraform state files and and directories with confirm message.\n\n" +
"Use --force to forcefully delete Terraform state files and directories for the component.\n\n" +
"- If no component is specified, the command will apply to all components and stacks.\n" +
"- If no stack is specified, the command will apply to all stacks for the specified component.\n" +
Expand Down
8 changes: 7 additions & 1 deletion internal/exec/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,14 @@ func processArgsAndFlags(componentType string, inputArgsAndFlags []string) (sche
var additionalArgsAndFlags []string
var globalOptions []string
var indexesToRemove []int
if len(inputArgsAndFlags) > 1 && inputArgsAndFlags[0] == "clean" {
if !u.SliceContainsString(inputArgsAndFlags, everythingFlag) {
inputArgsAndFlags = append(inputArgsAndFlags, everythingFlag)
}
}
fmt.Println(inputArgsAndFlags)

// For commands like `atmos terraform clean` and `atmos terraform plan`, show the command help
// For commands like `atmos terraform plan`, show the command help
if len(inputArgsAndFlags) == 1 && inputArgsAndFlags[0] != "version" {
info.SubCommand = inputArgsAndFlags[0]
info.NeedHelp = true
Expand Down
2 changes: 1 addition & 1 deletion website/docs/cli/commands/terraform/terraform-clean.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Execute the `terraform clean` command like this:
atmos terraform clean <component> -s <stack> [--skip-lock-file] [--everything] [--force]

:::warning
The `--everything` flag will delete all Terraform-related files including state files. The `--force` flag will bypass confirmation prompts.
The `--everything` flag is the default behavior and will delete all Terraform-related files including state files. The `--force` flag will bypass confirmation prompts.
Use these flags with extreme caution as they can lead to irreversible data loss.
:::
```
Expand Down
2 changes: 1 addition & 1 deletion website/docs/cli/commands/terraform/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ HCL-based domain-specific language and its interpreter. Atmos works with [OpenTo

- `atmos terraform clean` command deletes the `.terraform` folder, `.terraform.lock.hcl` lock file, and the previously generated `planfile`
and `varfile` for the specified component and stack. Use the `--skip-lock-file` flag to skip deleting the `.terraform.lock.hcl` file.
Use the `--everything` flag to delete all the local Terraform state files and directories (including `terraform.tfstate.d`) for all components and stacks.
Use the `--everything` flag is the default behavior to delete all the local Terraform state files and directories (including `terraform.tfstate.d`) for all components and stacks.
Use the `--force` flag to bypass the safety confirmation prompt and force the deletion (use with caution).

:::warning
Expand Down

0 comments on commit 0c90df5

Please sign in to comment.