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

Stack: clean #3871

Merged
merged 8 commits into from
Feb 12, 2025
Merged

Stack: clean #3871

merged 8 commits into from
Feb 12, 2025

Conversation

denis256
Copy link
Member

@denis256 denis256 commented Feb 11, 2025

Description

  • Add basic command for cleaning stacks directories
  • Added documentation for command
  • Extracted stack experiment check

RFC: #3313

TODOs

Read the Gruntwork contribution guidelines.

  • Update the docs.
  • Run the relevant tests successfully, including pre-commit checks.
  • Ensure any 3rd party code adheres with our license policy or delete this line if its not applicable.
  • Include release notes. If this PR is backward incompatible, include a migration guide.

Release Notes (draft)

Added / Removed / Updated [X].

Migration Guide

Summary by CodeRabbit

  • New Features
    • Introduced a new CLI command to clean the stack directory, making it easier to reset or troubleshoot the stack state.
    • Updated command naming for enhanced clarity, including a refined output command for consolidated viewing.
  • Documentation
    • Enhanced the CLI reference documentation with updated descriptions, examples, and flag details for the revised and new commands.
  • Tests
    • Added an integration test to validate that the stack cleaning functionality works as expected.

Copy link

vercel bot commented Feb 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
terragrunt-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 11, 2025 10:03pm

Copy link
Contributor

coderabbitai bot commented Feb 11, 2025

Walkthrough

The pull request refactors error handling for the stacks experiment in the stack command by introducing a new function, checkStackExperiment, and adds a new RunClean function for cleaning the stack directory. The CLI command constants were renamed for clarity, and a new command, cleanCommandName, was added. Documentation was updated to reflect the new command and renamed outputs, and an integration test was included to verify the stack cleanup functionality.

Changes

Files Change Summary
cli/commands/stack/action.go Added checkStackExperiment to centralize experiment error handling; added RunClean to remove the stack directory; added import for os package.
cli/commands/stack/command.go Renamed command constants (from generate, run, and output to generateCommandName, runCommandName, and outputCommandName); added cleanCommandName.
docs/_docs/04_reference/02-cli-options.md Updated command documentation to reflect the renaming of output to stack output and added documentation for the new stack clean command.
test/integration_stacks_test.go Added TestStacksApplyClean integration test to verify that the stack directory is properly created and subsequently removed by the clean command.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant C as CLI Parser
    participant R as RunClean Function
    participant OS as Operating System

    U->>C: Execute "stack clean" command
    C->>R: Call RunClean(opts)
    R->>R: Execute checkStackExperiment(opts)
    Note right of R: Return error if experiment disabled
    R->>OS: Attempt to remove stack directory
    OS-->>R: Return success/error status
    R-->>C: Return final result
    C-->>U: Output command result
Loading

Possibly related PRs

Suggested reviewers

  • yhakbar
  • levkohimins

Poem

In the code's calm, a new command sings,
With a gentle check before cleanup springs.
Stack errors now handled in a single glance,
And directories cleared with a swift command.
Cheers to clean code and a smoother advance!
🚀 Happy coding, let's take a dance!


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

#### stack clean

Running `terragrunt stack clean` removes the `.terragrunt-stack` directory, which is generated by the `terragrunt stack generate`
or `terragrunt stack run` commands. This can be useful when you need to reset the stack state or troubleshoot issues.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
or `terragrunt stack run` commands. This can be useful when you need to reset the stack state or troubleshoot issues.
or `terragrunt stack run` commands. This can be useful when you need to remove generated configurations or troubleshoot issues.

Avoid using the term "state" unless you're talking about OpenTofu/Terraform state.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
docs/_docs/04_reference/02-cli-options.md (1)

497-501: Improve clarity by avoiding the term "state".

Based on previous feedback, we should avoid using the term "state" unless specifically referring to OpenTofu/Terraform state.

Apply this diff to clarify the purpose:

-Running `terragrunt stack clean` removes the `.terragrunt-stack` directory, which is generated by the `terragrunt stack generate`
-or `terragrunt stack run` commands. This can be useful when you need to remove generated configurations or troubleshoot issues.
+Running `terragrunt stack clean` removes the `.terragrunt-stack` directory, which is generated by `terragrunt stack generate`
+or `terragrunt stack run` commands. This can be useful when you need to remove generated configurations or troubleshoot issues.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a39ed72 and 412ec3c.

📒 Files selected for processing (1)
  • docs/_docs/04_reference/02-cli-options.md (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: unessential
  • GitHub Check: build-and-test
  • GitHub Check: Pull Request has non-contributor approval
🔇 Additional comments (1)
docs/_docs/04_reference/02-cli-options.md (1)

369-496: Great job on the comprehensive documentation!

The stack output command documentation is thorough, well-structured, and includes clear examples for all supported formats. The examples effectively demonstrate both basic and advanced usage patterns.

@denis256 denis256 merged commit a02986e into main Feb 12, 2025
8 of 9 checks passed
@denis256 denis256 deleted the tg-840-stack-clean branch February 12, 2025 13:58
@coderabbitai coderabbitai bot mentioned this pull request Feb 21, 2025
4 tasks
@coderabbitai coderabbitai bot mentioned this pull request Mar 12, 2025
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants