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

Added --output-folder flag to scaffold #3805

Merged

Conversation

KabaevRoman
Copy link
Contributor

@KabaevRoman KabaevRoman commented Jan 26, 2025

Description

Added --output-folder flag for scaffold

Fixes #3652.

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].
Added --output-folder flag for scaffold

Migration Guide

Summary by CodeRabbit

  • New Features

    • Introduced an --output-folder flag for the scaffolding command, allowing users to specify a custom location for generated files (defaulting to the working directory if not set).
  • Documentation

    • Updated the catalog command documentation to reflect the new output folder option, enhancing clarity on how to manage file output locations.

// scaffold only in empty directories
if empty, err := util.IsDirectoryEmpty(opts.WorkingDir); !empty || err != nil {
if err != nil {
return err
}

opts.Logger.Warnf("The working directory %s is not empty.", opts.WorkingDir)
opts.Logger.Warnf("The woring directory %s is not empty.", opts.WorkingDir)
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's an accidental typo here ^

@yhakbar
Copy link
Collaborator

yhakbar commented Jan 28, 2025

I'm going to avoid merging this in for now, as we have a lot of other CLI Redesign work in-flight, but it looks good to me.

Will merge this in if we don't get those changes to the CLI merged in relatively soon.

@yhakbar yhakbar added the preserved Preserved issues never go stale label Jan 31, 2025
@yhakbar
Copy link
Collaborator

yhakbar commented Feb 10, 2025

Hey @KabaevRoman !

We've recently done a lot of work on the CLI Redesign, and that's caused some conflicts here. Are you willing to rebase your work?

@KabaevRoman
Copy link
Contributor Author

@yhakbar, got it i'll try to update it with fixes and conflict resolution tomorrow

@KabaevRoman KabaevRoman force-pushed the feature/scaffold-output-folder branch from 631b035 to a9bd4da Compare February 11, 2025 20:47
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 8:48pm

Copy link
Contributor

coderabbitai bot commented Feb 11, 2025

Walkthrough

This pull request introduces a new flag and related functionality to allow users to specify an output directory for the scaffolded files. The changes update logging messages, the configuration object, and the boilerplate options to use an output folder derived from the new flag. Documentation and tests have been updated to mirror these modifications, ensuring the new functionality integrates with the existing scaffolding workflow without altering error handling or core logic.

Changes

File(s) Change Summary
cli/commands/scaffold/action.go, cli/commands/scaffold/command.go, options/.../options.go, docs/_docs/02_features/05-catalog.md Added and integrated the --output-folder flag: introduced a new variable (outputDir), updated log messages and configuration to use this variable, and revised docs to include the new flag.
test/integration_scaffold_test.go Added a new integration test (TestScaffoldOutputFolderFlag) to verify that the scaffold command correctly processes the --output-folder flag and places output as expected.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant CLI as Terragrunt CLI
    participant Action as Scaffold Action
    participant Logger as Logger

    U->>CLI: Run "terragrunt scaffold" with --output-folder
    CLI->>Action: Pass options with ScaffoldOutputFolder value
    Action->>Action: Determine outputDir (flag value or default WorkingDir)
    Action->>Logger: Log scaffolding messages using outputDir
    Logger-->>U: Display status messages
Loading

Assessment against linked issues

Objective Addressed Explanation
Specify a custom output directory for scaffolded terragrunt.hcl file (#3652)

Poem

In our code a new flag gleams,
Guiding outputs like dreams,
Directing files to a chosen gate,
Ensuring paths align just great,
Happy bytes dance in delight 🚀✨
Code sings in a custom flight!

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 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.

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

🔭 Outside diff range comments (1)
cli/commands/scaffold/action.go (1)

124-131: ⚠️ Potential issue

Directory check should be performed on the output directory.

The empty directory check is currently performed on opts.WorkingDir, but it should be checking outputDir since that's where the files will be created.

Apply this diff to fix the issue:

-if empty, err := util.IsDirectoryEmpty(opts.WorkingDir); !empty || err != nil {
+if empty, err := util.IsDirectoryEmpty(outputDir); !empty || err != nil {
    if err != nil {
        return err
    }

-   opts.Logger.Warnf("The working directory %s is not empty.", opts.WorkingDir)
+   opts.Logger.Warnf("The output directory %s is not empty.", outputDir)
}
🧹 Nitpick comments (1)
docs/_docs/02_features/05-catalog.md (1)

55-55: Let's polish the flag documentation.

The description is good but could be even clearer with a few tweaks.

Here's a suggested improvement:

-- `--output-folder` - Location for generated `terragrunt.hcl`. If flag is not provided current working directory is selected.
+- `--output-folder` - Specifies the location for the generated `terragrunt.hcl` file. If this flag is not provided, the current working directory will be used.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~55-~55: You might be missing the article “a” here.
Context: ...tion for generated terragrunt.hcl. If flag is not provided current working directo...

(AI_EN_LECTOR_MISSING_DETERMINER_A)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3f47a90 and a9bd4da.

📒 Files selected for processing (5)
  • cli/commands/scaffold/action.go (4 hunks)
  • cli/commands/scaffold/command.go (2 hunks)
  • docs/_docs/02_features/05-catalog.md (2 hunks)
  • options/options.go (1 hunks)
  • test/integration_scaffold_test.go (1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/_docs/02_features/05-catalog.md

[uncategorized] ~55-~55: You might be missing the article “a” here.
Context: ...tion for generated terragrunt.hcl. If flag is not provided current working directo...

(AI_EN_LECTOR_MISSING_DETERMINER_A)

🔇 Additional comments (4)
cli/commands/scaffold/command.go (1)

20-20: LGTM! Nice addition of the output folder flag.

The flag is well-integrated into the existing flags structure with a clear usage description.

Also applies to: 58-62

test/integration_scaffold_test.go (1)

193-203: Great test coverage for the new flag!

The test effectively verifies that the --output-folder flag works as expected by checking both successful execution and file creation in the specified directory.

options/options.go (1)

314-315: LGTM! Well-documented field addition.

The new ScaffoldOutputFolder field is properly documented and logically grouped with other scaffold-related fields.

docs/_docs/02_features/05-catalog.md (1)

19-19: Looking good! Command signature updated correctly.

The new --output-folder flag has been properly added to the command signature with the correct optional syntax.

@KabaevRoman
Copy link
Contributor Author

@yhakbar rebased pr and fixed typo, would be nice to trigger pipelines

@KabaevRoman KabaevRoman requested a review from yhakbar February 13, 2025 11:56
@yhakbar yhakbar merged commit 0b550a3 into gruntwork-io:main Feb 18, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preserved Preserved issues never go stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

output-folder flag for scaffold
2 participants