atmos icon indicating copy to clipboard operation
atmos copied to clipboard

clean user files set by user

Open samtholiya opened this issue 7 months ago β€’ 16 comments

what

  • we add a clean yaml config that will help user's delete the folders/files that also needs to be cleaned during terraform clean.

why

  • This will help users to clean other files that might be created due their modules that is not included in terraform clean.

references

Summary by CodeRabbit

  • New Features

    • Delete custom files during cleanup using glob patterns; user-specified paths are removed before standard cleanup and shown in confirmation messaging.
  • Behavior

    • File-matching now evaluates directory entries too, improving pattern matching and traversal results.
  • Documentation

    • Updated terraform-clean docs with examples for custom file deletion; added blog post announcing the feature.
  • Tests

    • Added unit tests for deletion messaging, pattern extraction/matching, and deletion workflows.
  • Chores

    • Updated dependency manifest and license notices.

samtholiya avatar Jul 27 '25 19:07 samtholiya

Codecov Report

:x: Patch coverage is 81.25000% with 24 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 69.79%. Comparing base (f21e0b4) to head (d40a6b6). :warning: Report is 42 commits behind head on main.

Files with missing lines Patch % Lines
internal/exec/clean.go 83.01% 9 Missing and 9 partials :warning:
internal/exec/terraform_clean.go 70.00% 3 Missing and 3 partials :warning:
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1381      +/-   ##
==========================================
+ Coverage   69.75%   69.79%   +0.03%     
==========================================
  Files         397      398       +1     
  Lines       36324    36438     +114     
==========================================
+ Hits        25337    25431      +94     
- Misses       8674     8685      +11     
- Partials     2313     2322       +9     
Flag Coverage Ξ”
unittests 69.79% <81.25%> (+0.03%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Ξ”
pkg/filematch/filematch.go 82.45% <100.00%> (ΓΈ)
internal/exec/terraform_clean.go 29.96% <70.00%> (+3.66%) :arrow_up:
internal/exec/clean.go 83.01% <83.01%> (ΓΈ)

... and 5 files with indirect coverage changes

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Jul 27 '25 19:07 codecov[bot]

πŸ“ Walkthrough

Walkthrough

Adds support for deleting user-configured files during atmos terraform clean: collect glob patterns from component settings, match paths, delete user files before standard cleanup, update confirmation messaging, add a filesystem abstraction and gomock mocks, and include tests, docs, and notice/go.mod updates.

Changes

Cohort / File(s) Summary
Dependency & Notices
go.mod, NOTICE
Added test/dev deps (github.com/alecthomas/assert/v2, github.com/golang/mock v1.6.0); adjusted NOTICE entries and a go-getter version change.
Core Clean Functionality
internal/exec/clean.go
New exported APIs GetFilesToBeDeleted(stackMap map[string]any, component, stack string) ([]string, error), DeletePaths([]string) error, and Filesystem interface; implements traversal of stacks/components, extraction of clean glob patterns, matching, deletion with logging and aggregated errors.
Terraform Clean Integration
internal/exec/terraform_clean.go
Integrates GetFilesToBeDeleted and DeletePaths into handleCleanSubCommand(), includes user files in totals/confirmation, adds getDeleteMessage(...), and switches import to github.com/pkg/errors.
File Matching
pkg/filematch/filematch.go
Directory entries now evaluated by the glob matcher (removed early return for directories); empty basePath defaults to "./".
Tests
internal/exec/clean_test.go, internal/exec/terraform_clean_test.go
Added unit tests for DeletePaths (real FS), deletePaths (mocked), isValidStack, extractCleanPatterns, and getDeleteMessage.
Mock Infrastructure
internal/exec/mock_file_utils.go
Generated GoMock MockFilesystem with Lstat, RemoveAll, and Stat methods for testing.
Docs & Blog
website/docs/cli/commands/terraform/terraform-clean.mdx, website/blog/2025-10-26-clean-user-files-set-by-user-.md
Documented "Delete custom files" config example and added a blog post describing the feature.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI as atmos CLI
    participant TFC as terraform_clean.go
    participant Clean as clean.go
    participant FS as Filesystem

    User->>CLI: atmos terraform clean
    CLI->>TFC: handleCleanSubCommand()
    TFC->>Clean: GetFilesToBeDeleted(stackMap, component, stack)
    Clean->>Clean: traverse stacks & components\nextract glob patterns
    Clean->>FS: match patterns against filesystem
    Clean-->>TFC: return matched user file paths
    TFC->>TFC: compute totals\ngetDeleteMessage(...)
    TFC->>Clean: DeletePaths(userFiles)
    Clean->>FS: RemoveAll(path) (log & verify)
    Clean-->>TFC: deletion result
    TFC->>TFC: proceed with standard cleanup
    TFC-->>User: cleanup complete

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Focus review on:
    • internal/exec/clean.go β€” traversal, glob extraction, path normalization and sanitization.
    • internal/exec/terraform_clean.go β€” integration points, totals/confirmation messaging, error paths.
    • pkg/filematch/filematch.go β€” directory-matching semantics change.
    • Tests and gomock in internal/exec/clean_test.go and internal/exec/mock_file_utils.go.

Possibly related PRs

  • cloudposse/atmos#1195 β€” similar changes to Terraform clean workflow and collecting component paths for deletion.
  • cloudposse/atmos#870 β€” overlaps in terraform-clean flow and confirmation logic modifications.
  • cloudposse/atmos#727 β€” related additions to deletion and confirmation behavior in terraform-clean.

Suggested reviewers

  • osterman
  • aknysh
  • kevcube

Pre-merge checks and finishing touches

βœ… Passed checks (4 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The PR title clearly describes the main change: adding support for users to specify custom files and paths to clean during terraform cleanup operations.
Linked Issues check βœ… Passed All DEV-3009 requirements are met: YAML config support for terraform.clean.paths added [go.mod, internal/exec/clean.go], glob pattern matching implemented [pkg/filematch/filematch.go], user-specified paths deleted before standard cleanup [internal/exec/terraform_clean.go], and path traversal prevention via validation [internal/exec/clean.go].
Out of Scope Changes check βœ… Passed Changes include minor dependency updates (go.mod), mock generation, documentation, and blog post additionsβ€”all directly supporting the core feature. No extraneous changes detected.
✨ Finishing touches
  • [ ] πŸ“ Generate docstrings
πŸ§ͺ Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment
  • [ ] Commit unit tests in branch feature/dev-3009-extend-atmos-terraform-clean-to-clean-up-custom-paths

πŸ“œ Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 1730e5568884711cf3fb3e30b2736b3b8545de10 and d40a6b689002af2d6ddf1a00e32d05bdebea58e3.

πŸ“’ Files selected for processing (1)
  • internal/exec/terraform_clean.go (4 hunks)
🧰 Additional context used
πŸ““ Path-based instructions (2)
**/*.go

πŸ“„ CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)

**/*.go: All code must pass golangci-lint checks Follow Go error handling idioms and use meaningful error messages Wrap errors with context using fmt.Errorf("context: %w", err) Consider custom error types for domain-specific errors Follow standard Go coding style; run gofmt and goimports Use snake_case for environment variables Document complex logic with inline comments

Files:

  • internal/exec/terraform_clean.go
**/!(*_test).go

πŸ“„ CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)

Document all exported functions, types, and methods with Go doc comments

Files:

  • internal/exec/terraform_clean.go
🧠 Learnings (34)
πŸ““ Common learnings
Learnt from: Listener430
Repo: cloudposse/atmos PR: 934
File: tests/fixtures/scenarios/docs-generate/README.md.gotmpl:99-118
Timestamp: 2025-01-25T03:51:57.689Z
Learning: For the cloudposse/atmos repository, changes to template contents should be handled in dedicated PRs and are typically considered out of scope for PRs focused on other objectives.
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1466
File: toolchain/http_client_test.go:3-10
Timestamp: 2025-09-10T21:17:55.273Z
Learning: In the cloudposse/atmos repository, imports should never be changed as per samtholiya's coding guidelines.
Learnt from: osterman
Repo: cloudposse/atmos PR: 727
File: internal/exec/terraform.go:114-118
Timestamp: 2024-10-21T17:51:53.976Z
Learning: When `atmos terraform clean --everything` is used without specifying a component and without the `--force` flag, prompt the user for confirmation before deleting all components. Use the `--force` flag to skip the confirmation prompt.
Learnt from: osterman
Repo: cloudposse/atmos PR: 727
File: internal/exec/terraform_clean.go:329-332
Timestamp: 2024-10-28T01:51:30.811Z
Learning: In the Atmos Go code, when deleting directories or handling file paths (e.g., in `terraform_clean.go`), always resolve the absolute path using `filepath.Abs` and use the logger `u.LogWarning` for logging messages instead of using `fmt.Printf`.
Learnt from: aknysh
Repo: cloudposse/atmos PR: 759
File: internal/exec/terraform.go:366-368
Timestamp: 2024-11-02T15:35:09.958Z
Learning: In `internal/exec/terraform.go`, the workspace cleaning code under both the general execution path and within the `case "init":` block is intentionally duplicated because the code execution paths are different. The `.terraform/environment` file should be deleted before executing `terraform init` in both scenarios to ensure a clean state.
Learnt from: aknysh
Repo: cloudposse/atmos PR: 775
File: internal/exec/template_funcs_component.go:157-159
Timestamp: 2024-11-12T03:16:02.910Z
Learning: In the Go code for `componentFunc` in `internal/exec/template_funcs_component.go`, the function `cleanTerraformWorkspace` does not return errors, and it's acceptable if the file does not exist. Therefore, error handling for `cleanTerraformWorkspace` is not needed.
Learnt from: osterman
Repo: cloudposse/atmos PR: 727
File: internal/exec/terraform.go:114-118
Timestamp: 2024-10-21T17:51:07.087Z
Learning: Use `bubbletea` for confirmation prompts instead of `fmt.Scanln` in the `atmos terraform clean` command.
Learnt from: osterman
Repo: cloudposse/atmos PR: 727
File: internal/exec/terraform_clean.go:233-235
Timestamp: 2024-10-31T19:25:41.298Z
Learning: When specifying color values in functions like `confirmDeleteTerraformLocal` in `internal/exec/terraform_clean.go`, avoid hardcoding color values. Instead, use predefined color constants or allow customization through configuration settings to improve accessibility and user experience across different terminals and themes.
Learnt from: haitham911
Repo: cloudposse/atmos PR: 727
File: internal/exec/terraform_clean.go:215-223
Timestamp: 2024-10-27T04:41:49.199Z
Learning: In `internal/exec/terraform_clean.go`, the function `determineCleanPath` is necessary and should not be removed.
Learnt from: osterman
Repo: cloudposse/atmos PR: 1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: Final XDG Base Directory Specification implementation for atmos toolchain is complete and verified: toolchain/xdg_cache.go provides GetXDGCacheDir() and GetXDGTempCacheDir() functions, all hardcoded ~/.cache/tools-cache paths have been replaced with XDG-compliant paths using ${XDG_CACHE_HOME}/atmos-toolchain (or ~/.cache/atmos-toolchain fallback), and tests have been updated to expect the new path structure.
Learnt from: osterman
Repo: cloudposse/atmos PR: 1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: XDG Base Directory Specification compliance implementation for atmos toolchain is complete: created toolchain/xdg_cache.go with GetXDGCacheDir() and GetXDGTempCacheDir() functions, updated toolchain/installer.go and cmd/toolchain_clean.go to use these XDG helpers, and changed all cache paths from hardcoded ~/.cache/tools-cache to XDG-compliant ${XDG_CACHE_HOME}/atmos-toolchain (or ~/.cache/atmos-toolchain fallback).
Learnt from: osterman
Repo: cloudposse/atmos PR: 1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: The atmos toolchain has been updated to follow XDG Base Directory Specification with helper functions GetXDGCacheDir() and GetXDGTempCacheDir() in toolchain/xdg_cache.go, using XDG_CACHE_HOME when set and falling back to ~/.cache/atmos-toolchain, making it consistent with atmos core's XDG compliance.
πŸ“š Learning: 2024-10-27T04:41:49.199Z
Learnt from: haitham911
Repo: cloudposse/atmos PR: 727
File: internal/exec/terraform_clean.go:215-223
Timestamp: 2024-10-27T04:41:49.199Z
Learning: In `internal/exec/terraform_clean.go`, the function `determineCleanPath` is necessary and should not be removed.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2024-11-02T15:35:09.958Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 759
File: internal/exec/terraform.go:366-368
Timestamp: 2024-11-02T15:35:09.958Z
Learning: In `internal/exec/terraform.go`, the workspace cleaning code under both the general execution path and within the `case "init":` block is intentionally duplicated because the code execution paths are different. The `.terraform/environment` file should be deleted before executing `terraform init` in both scenarios to ensure a clean state.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2024-11-24T19:13:10.287Z
Learnt from: haitham911
Repo: cloudposse/atmos PR: 727
File: internal/exec/terraform_clean.go:407-416
Timestamp: 2024-11-24T19:13:10.287Z
Learning: In `internal/exec/terraform_clean.go`, when `getStackTerraformStateFolder` returns an error in the `handleCleanSubCommand` function, the error is logged, and the process continues without returning the error.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2024-11-12T03:16:02.910Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 775
File: internal/exec/template_funcs_component.go:157-159
Timestamp: 2024-11-12T03:16:02.910Z
Learning: In the Go code for `componentFunc` in `internal/exec/template_funcs_component.go`, the function `cleanTerraformWorkspace` does not return errors, and it's acceptable if the file does not exist. Therefore, error handling for `cleanTerraformWorkspace` is not needed.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2025-04-26T15:54:10.506Z
Learnt from: haitham911
Repo: cloudposse/atmos PR: 1195
File: internal/exec/terraform_clean.go:99-99
Timestamp: 2025-04-26T15:54:10.506Z
Learning: The error variable `ErrRelPath` is defined in `internal/exec/terraform_clean_util.go` and is used across files in the `exec` package, including in `terraform_clean.go`. This is part of an approach to standardize error handling in the codebase.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2024-10-27T04:28:40.966Z
Learnt from: haitham911
Repo: cloudposse/atmos PR: 727
File: internal/exec/terraform_clean.go:155-175
Timestamp: 2024-10-27T04:28:40.966Z
Learning: In the `CollectDirectoryObjects` function in `internal/exec/terraform_clean.go`, recursive search through all subdirectories is not needed.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2024-10-31T19:25:41.298Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 727
File: internal/exec/terraform_clean.go:233-235
Timestamp: 2024-10-31T19:25:41.298Z
Learning: When specifying color values in functions like `confirmDeleteTerraformLocal` in `internal/exec/terraform_clean.go`, avoid hardcoding color values. Instead, use predefined color constants or allow customization through configuration settings to improve accessibility and user experience across different terminals and themes.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2024-10-30T13:25:45.965Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 727
File: internal/exec/terraform_clean.go:405-412
Timestamp: 2024-10-30T13:25:45.965Z
Learning: In `internal/exec/terraform_clean.go`, when appending `stackFolders` to `folders` in the `handleCleanSubCommand` function, it's unnecessary to check if `stackFolders` is nil before appending, because in Go, appending a nil slice is safe and does not cause a panic.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2024-10-28T01:51:30.811Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 727
File: internal/exec/terraform_clean.go:329-332
Timestamp: 2024-10-28T01:51:30.811Z
Learning: In the Atmos Go code, when deleting directories or handling file paths (e.g., in `terraform_clean.go`), always resolve the absolute path using `filepath.Abs` and use the logger `u.LogWarning` for logging messages instead of using `fmt.Printf`.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2025-04-11T22:06:46.999Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1147
File: internal/exec/validate_schema.go:42-57
Timestamp: 2025-04-11T22:06:46.999Z
Learning: The "ExecuteAtmosValidateSchemaCmd" function in internal/exec/validate_schema.go has been reviewed and confirmed to have acceptable cognitive complexity despite static analysis warnings. The function uses a clean structure with only three if statements for error handling and delegates complex operations to helper methods.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2024-12-02T21:26:32.337Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 808
File: pkg/config/config.go:478-483
Timestamp: 2024-12-02T21:26:32.337Z
Learning: In the 'atmos' project, when reviewing Go code like `pkg/config/config.go`, avoid suggesting file size checks after downloading remote configs if such checks aren't implemented elsewhere in the codebase.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2024-10-23T21:36:40.262Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 740
File: cmd/cmd_utils.go:340-359
Timestamp: 2024-10-23T21:36:40.262Z
Learning: In the Go codebase for Atmos, when reviewing functions like `checkAtmosConfig` in `cmd/cmd_utils.go`, avoid suggesting refactoring to return errors instead of calling `os.Exit` if such changes would significantly increase the scope due to the need to update multiple call sites.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2025-09-13T16:39:20.007Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1466
File: cmd/markdown/atmos_toolchain_aliases.md:2-4
Timestamp: 2025-09-13T16:39:20.007Z
Learning: In the cloudposse/atmos repository, CLI documentation files in cmd/markdown/ follow a specific format that uses " $ atmos command" (with leading space and dollar sign prompt) in code blocks. This is the established project convention and should not be changed to comply with standard markdownlint rules MD040 and MD014.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2025-09-10T21:17:55.273Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1466
File: toolchain/http_client_test.go:3-10
Timestamp: 2025-09-10T21:17:55.273Z
Learning: In the cloudposse/atmos repository, imports should never be changed as per samtholiya's coding guidelines.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2025-11-01T20:24:29.557Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1714
File: NOTICE:0-0
Timestamp: 2025-11-01T20:24:29.557Z
Learning: In the cloudposse/atmos repository, the NOTICE file is programmatically generated and should not be manually edited. Issues with dependency license URLs in NOTICE will be resolved when upstream package metadata is corrected.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2024-11-22T12:38:33.132Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 768
File: internal/exec/vendor_utils.go:496-513
Timestamp: 2024-11-22T12:38:33.132Z
Learning: In the Atmos project, continue to flag path traversal issues in code reviews but acknowledge when they are expected and acceptable in specific cases.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2025-09-13T18:06:07.674Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1466
File: toolchain/list.go:39-42
Timestamp: 2025-09-13T18:06:07.674Z
Learning: In the cloudposse/atmos repository, for UI messages in the toolchain package, use utils.PrintfMessageToTUI instead of log.Error or fmt.Fprintln(os.Stderr, ...). Import pkg/utils with alias "u" to follow the established pattern.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2025-07-05T20:59:02.914Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 1363
File: internal/exec/template_utils.go:18-18
Timestamp: 2025-07-05T20:59:02.914Z
Learning: In the Atmos project, gomplate v4 is imported with a blank import (`_ "github.com/hairyhenderson/gomplate/v4"`) alongside v3 imports to resolve AWS SDK version conflicts. V3 uses older AWS SDK versions that conflict with newer AWS modules used by Atmos. A full migration to v4 requires extensive refactoring due to API changes and should be handled in a separate PR.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2024-10-31T07:09:31.983Z
Learnt from: Cerebrovinny
Repo: cloudposse/atmos PR: 737
File: internal/exec/vendor_utils.go:181-182
Timestamp: 2024-10-31T07:09:31.983Z
Learning: In `internal/exec/vendor_utils.go`, the variables `mergedSources` and `mergedImports` are declared and used later in the code. Do not suggest removing them as unused variables.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2025-10-10T23:51:36.597Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1599
File: internal/exec/terraform.go:394-402
Timestamp: 2025-10-10T23:51:36.597Z
Learning: In Atmos (internal/exec/terraform.go), when adding OpenTofu-specific flags like `--var-file` for `init`, do not gate them based on command name (e.g., checking if `info.Command == "tofu"` or `info.Command == "opentofu"`) because command names don't reliably indicate the actual binary being executed (symlinks, aliases). Instead, document the OpenTofu requirement in code comments and documentation, trusting users who enable the feature (e.g., `PassVars`) to ensure their terraform command points to an OpenTofu binary.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2025-02-05T11:10:51.031Z
Learnt from: mss
Repo: cloudposse/atmos PR: 1024
File: internal/exec/go_getter_utils.go:31-33
Timestamp: 2025-02-05T11:10:51.031Z
Learning: The path traversal check in `ValidateURI` function in `internal/exec/go_getter_utils.go` is intentionally kept despite potentially blocking valid Git URLs, as this validation is planned to be addressed in a separate ticket.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2024-12-25T20:28:19.618Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 887
File: internal/exec/workflow_utils.go:167-169
Timestamp: 2024-12-25T20:28:19.618Z
Learning: The user plans to revert the change from `path.Join` to `filepath.Join` in this PR due to testing gaps and will open a new PR to safely handle the migration without breaking `main`.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2024-10-21T17:51:53.976Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 727
File: internal/exec/terraform.go:114-118
Timestamp: 2024-10-21T17:51:53.976Z
Learning: When `atmos terraform clean --everything` is used without specifying a component and without the `--force` flag, prompt the user for confirmation before deleting all components. Use the `--force` flag to skip the confirmation prompt.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2024-10-21T17:51:07.087Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 727
File: internal/exec/terraform.go:114-118
Timestamp: 2024-10-21T17:51:07.087Z
Learning: Use `bubbletea` for confirmation prompts instead of `fmt.Scanln` in the `atmos terraform clean` command.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to cmd/**/*.go : Provide clear error messages to users and troubleshooting hints where appropriate

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to **/*.go : Follow Go error handling idioms and use meaningful error messages

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to **/*_test.go : Test both happy paths and error conditions

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to **/*.go : Wrap errors with context using fmt.Errorf("context: %w", err)

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2025-10-02T19:17:51.630Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1504
File: pkg/profiler/profiler.go:20-31
Timestamp: 2025-10-02T19:17:51.630Z
Learning: In pkg/profiler/profiler.go, profiler-specific errors (ErrUnsupportedProfileType, ErrStartCPUProfile, ErrStartTraceProfile, ErrCreateProfileFile) must remain local and cannot be moved to errors/errors.go due to an import cycle: pkg/profiler β†’ errors β†’ pkg/schema β†’ pkg/profiler. This is a valid exception to the centralized errors policy.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2025-10-22T14:55:44.014Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1695
File: pkg/auth/manager.go:169-171
Timestamp: 2025-10-22T14:55:44.014Z
Learning: Go 1.20+ supports multiple %w verbs in fmt.Errorf, which returns an error implementing Unwrap() []error. This is valid and does not panic. Atmos uses Go 1.24.8 and configures errorlint with errorf-multi: true to validate this pattern.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2024-12-05T22:33:40.955Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 820
File: cmd/list_components.go:53-54
Timestamp: 2024-12-05T22:33:40.955Z
Learning: In the Atmos CLI Go codebase, using `u.LogErrorAndExit` within completion functions is acceptable because it logs the error and exits the command execution.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2024-10-27T04:54:32.397Z
Learnt from: haitham911
Repo: cloudposse/atmos PR: 727
File: internal/exec/terraform_clean.go:314-319
Timestamp: 2024-10-27T04:54:32.397Z
Learning: When deleting empty folders in the `deleteFolders` function, handling errors from `os.Remove` are not required, as failures do not affect the process.

Applied to files:

  • internal/exec/terraform_clean.go
πŸ“š Learning: 2024-10-27T04:34:08.011Z
Learnt from: haitham911
Repo: cloudposse/atmos PR: 727
File: internal/exec/terraform_clean.go:183-187
Timestamp: 2024-10-27T04:34:08.011Z
Learning: In the `getStackTerraformStateFolder` function, it's acceptable and not an error if no Terraform state folders are found for a stack.

Applied to files:

  • internal/exec/terraform_clean.go
🧬 Code graph analysis (1)
internal/exec/terraform_clean.go (3)
internal/exec/clean.go (2)
  • GetFilesToBeDeleted (13-26)
  • DeletePaths (185-189)
pkg/utils/log_utils.go (2)
  • PrintfMessageToTUI (33-35)
  • PrintMessage (21-23)
pkg/ui/theme/colors.go (1)
  • Styles (39-71)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Analyze (go)
  • GitHub Check: Lint (golangci)
  • GitHub Check: Build (windows)
  • GitHub Check: Build (linux)
  • GitHub Check: Analyze (go)
  • GitHub Check: Lint (golangci)
  • GitHub Check: autofix
  • GitHub Check: website-deploy-preview
  • GitHub Check: Review Dependency Licenses
πŸ”‡ Additional comments (1)
internal/exec/terraform_clean.go (1)

511-514: Good error handling.

Error is properly wrapped with context here.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Jul 31 '25 21:07 coderabbitai[bot]

@samtholiya this is missing documentation

osterman avatar Aug 18 '25 15:08 osterman

πŸ’₯ This pull request now has conflicts. Could you fix it @samtholiya? πŸ™

mergify[bot] avatar Sep 03 '25 05:09 mergify[bot]

πŸ’₯ This pull request now has conflicts. Could you fix it @samtholiya? πŸ™

mergify[bot] avatar Sep 27 '25 21:09 mergify[bot]

πŸ’₯ This pull request now has conflicts. Could you fix it @samtholiya? πŸ™

mergify[bot] avatar Sep 30 '25 14:09 mergify[bot]

[!WARNING]

This PR exceeds the recommended limit of 1,000 lines.

Large PRs are difficult to review and may be rejected due to their size.

Please verify that this PR does not address multiple issues. Consider refactoring it into smaller, more focused PRs to facilitate a smoother review process.

mergify[bot] avatar Oct 04 '25 19:10 mergify[bot]

πŸ’₯ This pull request now has conflicts. Could you fix it @samtholiya? πŸ™

mergify[bot] avatar Oct 06 '25 17:10 mergify[bot]

πŸ’₯ This pull request now has conflicts. Could you fix it @samtholiya? πŸ™

mergify[bot] avatar Oct 15 '25 02:10 mergify[bot]

[!WARNING]

Changelog Entry Required

This PR is labeled minor or major but doesn't include a changelog entry.

Action needed: Add a new blog post in website/blog/ to announce this change.

Example filename: website/blog/2025-10-26-feature-name.mdx

Alternatively: If this change doesn't require a changelog entry, remove the minor or major label.

github-actions[bot] avatar Oct 26 '25 15:10 github-actions[bot]

[!WARNING]

Changelog Entry Required

This PR is labeled minor or major but doesn't include a changelog entry.

Action needed: Add a new blog post in website/blog/ to announce this change.

Example filename: website/blog/2025-10-26-feature-name.mdx

Alternatively: If this change doesn't require a changelog entry, remove the minor or major label.

github-actions[bot] avatar Oct 26 '25 15:10 github-actions[bot]

[!WARNING]

Changelog Entry Required

This PR is labeled minor or major but doesn't include a changelog entry.

Action needed: Add a new blog post in website/blog/ to announce this change.

Example filename: website/blog/2025-10-26-feature-name.mdx

Alternatively: If this change doesn't require a changelog entry, remove the minor or major label.

github-actions[bot] avatar Oct 26 '25 15:10 github-actions[bot]

Dependency Review

βœ… No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails
gomod/github.com/alecthomas/assert/v2 2.11.0 :green_circle: 3.5
Details
CheckScoreReason
Packaging:warning: -1packaging workflow not detected
Maintained:warning: 01 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Code-Review:warning: 1Found 5/30 approved changesets -- score normalized to 1
Dangerous-Workflow:green_circle: 10no dangerous workflow patterns detected
Pinned-Dependencies:warning: 0dependency not pinned by hash detected -- score normalized to 0
Binary-Artifacts:green_circle: 10no binaries found in the repo
Token-Permissions:warning: 0detected GitHub workflow tokens with excessive permissions
CII-Best-Practices:warning: 0no effort to earn an OpenSSF best practices badge detected
Security-Policy:warning: 0security policy file not detected
Fuzzing:warning: 0project is not fuzzed
License:green_circle: 10license file detected
Signed-Releases:warning: -1no releases found
Vulnerabilities:green_circle: 100 existing vulnerabilities detected
Branch-Protection:warning: 0branch protection not enabled on development/release branches
SAST:warning: 0SAST tool is not run on all commits -- score normalized to 0
gomod/github.com/alecthomas/repr 0.5.2 :green_circle: 3.7
Details
CheckScoreReason
Binary-Artifacts:green_circle: 10no binaries found in the repo
Dangerous-Workflow:green_circle: 10no dangerous workflow patterns detected
Code-Review:warning: 2Found 5/23 approved changesets -- score normalized to 2
Packaging:warning: -1packaging workflow not detected
Maintained:warning: 12 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1
Pinned-Dependencies:warning: 0dependency not pinned by hash detected -- score normalized to 0
Token-Permissions:warning: 0detected GitHub workflow tokens with excessive permissions
CII-Best-Practices:warning: 0no effort to earn an OpenSSF best practices badge detected
Security-Policy:warning: 0security policy file not detected
Fuzzing:warning: 0project is not fuzzed
License:green_circle: 10license file detected
Signed-Releases:warning: -1no releases found
Branch-Protection:warning: 0branch protection not enabled on development/release branches
Vulnerabilities:green_circle: 100 existing vulnerabilities detected
SAST:warning: 0SAST tool is not run on all commits -- score normalized to 0
gomod/github.com/golang/mock 1.6.0 :green_circle: 3.9
Details
CheckScoreReason
Code-Review:green_circle: 5Found 16/30 approved changesets -- score normalized to 5
Token-Permissions:warning: 0detected GitHub workflow tokens with excessive permissions
Maintained:warning: 0project is archived
Dangerous-Workflow:green_circle: 10no dangerous workflow patterns detected
Packaging:warning: -1packaging workflow not detected
Binary-Artifacts:green_circle: 10no binaries found in the repo
Pinned-Dependencies:warning: 0dependency not pinned by hash detected -- score normalized to 0
CII-Best-Practices:warning: 0no effort to earn an OpenSSF best practices badge detected
License:green_circle: 10license file detected
Fuzzing:warning: 0project is not fuzzed
Signed-Releases:warning: 0Project has not signed or included provenance with any releases.
Security-Policy:warning: 0security policy file not detected
Branch-Protection:warning: -1internal error: error during branchesHandler.setup: internal error: some github tokens can't read classic branch protection rules: https://github.com/ossf/scorecard-action/blob/main/docs/authentication/fine-grained-auth-token.md
Vulnerabilities:green_circle: 100 existing vulnerabilities detected
SAST:warning: 0SAST tool is not run on all commits -- score normalized to 0
gomod/github.com/hashicorp/go-getter 1.8.2 :green_circle: 6.9
Details
CheckScoreReason
Maintained:green_circle: 1025 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Code-Review:green_circle: 10all changesets reviewed
Binary-Artifacts:green_circle: 10no binaries found in the repo
Dangerous-Workflow:green_circle: 10no dangerous workflow patterns detected
CII-Best-Practices:warning: 0no effort to earn an OpenSSF best practices badge detected
Token-Permissions:warning: 0detected GitHub workflow tokens with excessive permissions
Pinned-Dependencies:green_circle: 9dependency not pinned by hash detected -- score normalized to 9
Fuzzing:warning: 0project is not fuzzed
License:green_circle: 10license file detected
Vulnerabilities:green_circle: 100 existing vulnerabilities detected
Security-Policy:green_circle: 10security policy file detected
Signed-Releases:green_circle: 84 out of the last 4 releases have a total of 4 signed artifacts.
Packaging:green_circle: 10packaging workflow detected
Branch-Protection:warning: 1branch protection is not maximal on development and all release branches
SAST:warning: 0SAST tool is not run on all commits -- score normalized to 0

Scanned Files

  • go.mod

github-actions[bot] avatar Oct 26 '25 15:10 github-actions[bot]

πŸ’₯ This pull request now has conflicts. Could you fix it @samtholiya? πŸ™

mergify[bot] avatar Nov 02 '25 15:11 mergify[bot]

πŸ’₯ This pull request now has conflicts. Could you fix it @samtholiya? πŸ™

mergify[bot] avatar Nov 03 '25 16:11 mergify[bot]

πŸ’₯ This pull request now has conflicts. Could you fix it @samtholiya? πŸ™

mergify[bot] avatar Nov 25 '25 15:11 mergify[bot]