-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add --no-dependency-prompt
option for scaffold
#4420
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
feat: add --no-dependency-prompt
option for scaffold
#4420
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
📝 WalkthroughWalkthroughA new boolean CLI flag, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant TerragruntOptions
participant ScaffoldCommand
participant BoilerplateOptions
User->>CLI: Run 'terragrunt scaffold --no-dependency-prompt'
CLI->>TerragruntOptions: Parse flags, set NoDependencyPrompt
CLI->>ScaffoldCommand: Call Run with TerragruntOptions
ScaffoldCommand->>BoilerplateOptions: Pass DisableDependencyPrompt (from NoDependencyPrompt)
BoilerplateOptions-->>ScaffoldCommand: Use DisableDependencyPrompt to control prompts
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Suggested labels
Suggested reviewers
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (9)
🚧 Files skipped from review as they are similar to previous changes (9)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (3)
cli/commands/scaffold/cli.go (2)
21-27
: Constant name deviates from existing naming conventionAll other flag constants are suffixed with
FlagName
(RootFileNameFlagName
,VarFileFlagName
, …). Renaming for consistency improves readability and grep-ability.- DisableDependencyPrompt = "disable-dependency-prompt" + DisableDependencyPromptFlagName = "disable-dependency-prompt"Subsequent references in this file would need the same rename.
83-89
: Nice addition – environment variable automatically supportedThe flag is wired with
tgPrefix.EnvVars
, soTERRAGRUNT_DISABLE_DEPENDENCY_PROMPT
will work out-of-the-box. Consider documenting this in the scaffold docs for completeness.cli/commands/scaffold/scaffold_test.go (1)
65-74
: Test kept in sync – consider a positive-case testThe new field is included, which protects against regressions.
Optional: add a test exercisingDisableDependencyPrompt: true
to ensure the underlying boilerplate logic really skips the confirmation prompt.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
cli/commands/scaffold/cli.go
(2 hunks)cli/commands/scaffold/scaffold.go
(1 hunks)cli/commands/scaffold/scaffold_test.go
(1 hunks)docs/_docs/02_features/07-scaffold.md
(2 hunks)options/options.go
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`docs/**/*.md`: Review the documentation for clarity, grammar, and spelling. Make sure that the documentation is easy to understand and follow. There is currently a migration under...
docs/**/*.md
: Review the documentation for clarity, grammar, and spelling. Make sure that the documentation is easy to understand and follow. There is currently a migration underway from the Jekyll based documentation indocs
to the Starlight + Astro based documentation indocs-starlight
. Whenever changes are made to thedocs
directory, ensure that an equivalent change is made in thedocs-starlight
directory to keep thedocs-starlight
documentation accurate.
docs/_docs/02_features/07-scaffold.md
`**/*.go`: Review the Go code for quality and correctness. Make sure that the Go code follows best practices, is performant, and is easy to understand and maintain.
**/*.go
: Review the Go code for quality and correctness. Make sure that the Go code follows best practices, is performant, and is easy to understand and maintain.
cli/commands/scaffold/scaffold_test.go
cli/commands/scaffold/scaffold.go
options/options.go
cli/commands/scaffold/cli.go
🧬 Code Graph Analysis (4)
cli/commands/scaffold/scaffold_test.go (1)
cli/commands/scaffold/cli.go (1)
DisableDependencyPrompt
(26-26)
cli/commands/scaffold/scaffold.go (1)
cli/commands/scaffold/cli.go (1)
DisableDependencyPrompt
(26-26)
options/options.go (1)
cli/commands/scaffold/cli.go (1)
DisableDependencyPrompt
(26-26)
cli/commands/scaffold/cli.go (2)
cli/flags/flag.go (1)
NewFlag
(28-41)internal/cli/bool_flag.go (1)
BoolFlag
(13-49)
🔇 Additional comments (2)
options/options.go (1)
313-315
: New option field is well-integrated.The
DisableDependencyPrompt
flag is correctly added to the struct and initialised with a sane default; no functional or stylistic issues spotted.Also applies to: 421-422
cli/commands/scaffold/scaffold.go (1)
198-208
: Propagation of the new flag looks correctThe flag is forwarded to
boilerplate_options.BoilerplateOptions
, so scaffold generation will respect the setting. No additional concerns here.
```bash | ||
terragrunt scaffold <MODULE_URL> [TEMPLATE_URL] [--var] [--var-file] [--no-include-root] [--root-file-name] | ||
terragrunt scaffold <MODULE_URL> [TEMPLATE_URL] [--var] [--var-file] [--no-include-root] [--root-file-name] [--disable-dependency-prompt] | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs-starlight copy missing
Per contribution guidelines, every change under docs/
must be mirrored in docs-starlight/
. Please replicate the new flag description there to keep the two doc sets in sync.
Also applies to: 108-109
🤖 Prompt for AI Agents
In docs/_docs/02_features/07-scaffold.md around lines 18 to 20 and also lines
108 to 109, the new flag description added in the docs/ directory is missing in
the docs-starlight/ directory. To fix this, replicate the exact changes made for
the new flag description from docs/_docs/02_features/07-scaffold.md into the
corresponding file and lines in docs-starlight/_docs/02_features/07-scaffold.md
to keep both documentation sets synchronized.
--disable-dependency-prompt
option for scaffold
81b8ecc
to
ab96332
Compare
Hey @markoeremija , Thanks for submitting this PR. Could you please take a look at the following rules and make sure this flag follows them? I think at the least |
Hey @yhakbar, thanks for taking a look. I will check the rules out and try to implement the |
ab96332
to
1cd2d95
Compare
--disable-dependency-prompt
option for scaffold--no-dependency-prompt
option for scaffold
1cd2d95
to
8ca3b46
Compare
8ca3b46
to
8b4d342
Compare
Deployment failed with the following error:
|
There was a problem hiding this 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 (2)
docs-starlight/src/content/docs/02-features/07-scaffold.md (2)
14-15
: Add missing pipe separator before optional flags to keep usage syntax consistentPrevious examples in the docs show the optional flags grouped with a single pair of square brackets. Adding more flags without a preceding pipe character (
|
) can be confusing. Consider clarifying with individual brackets or clearly noting[...]
indicates any number of optional flags.
105-106
: Tighten wording to follow the style of the surrounding bullet listThe current phrasing is slightly verbose compared to the preceding bullets. Align the tone by leading with the action verb and removing the parenthetical clause.
- `--no-dependency-prompt` - Disable dependency confirmation, but keep the interactive mode enabled (skip asking for confirmation about including dependencies defined in the boilerplate template). + `--no-dependency-prompt` - Disable the prompt that asks whether to include dependencies defined in the boilerplate template while keeping interactive mode enabled.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
cli/commands/scaffold/cli.go
(2 hunks)cli/commands/scaffold/scaffold.go
(1 hunks)cli/commands/scaffold/scaffold_test.go
(1 hunks)docs-starlight/src/content/docs/02-features/07-scaffold.md
(2 hunks)docs/_docs/02_features/07-scaffold.md
(2 hunks)options/options.go
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
- docs/_docs/02_features/07-scaffold.md
- cli/commands/scaffold/scaffold_test.go
- options/options.go
- cli/commands/scaffold/cli.go
- cli/commands/scaffold/scaffold.go
🧰 Additional context used
📓 Path-based instructions (1)
`docs-starlight/**/*.md*`: Review the documentation for clarity, grammar, and sp...
docs-starlight/**/*.md*
: Review the documentation for clarity, grammar, and spelling. Make sure that the documentation is easy to understand and follow. There is currently a migration underway from the Jekyll based documentation indocs
to the Starlight + Astro based documentation indocs-starlight
. Make sure that thedocs-starlight
documentation is accurate and up-to-date with thedocs
documentation, and that any difference between them results in an improvement in thedocs-starlight
documentation.
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
docs-starlight/src/content/docs/02-features/07-scaffold.md
🧠 Learnings (1)
docs-starlight/src/content/docs/02-features/07-scaffold.md (2)
Learnt from: yhakbar
PR: gruntwork-io/terragrunt#3868
File: docs-starlight/patches/@astrojs%2Fstarlight@0.31.1.patch:33-33
Timestamp: 2025-02-10T23:20:04.295Z
Learning: In Terragrunt projects, all `.hcl` files can be assumed to be Terragrunt configurations by default, with specific exceptions like `.terraform.lock.hcl` that need explicit handling.
Learnt from: yhakbar
PR: gruntwork-io/terragrunt#4169
File: cli/commands/hcl/validate/cli.go:29-60
Timestamp: 2025-04-17T13:02:28.098Z
Learning: Avoid shadowing imported packages with local variables in Go code, such as using a variable named `flags` when the `github.com/gruntwork-io/terragrunt/cli/flags` package is imported. Use more specific variable names like `flagSet` instead.
@markoeremija would it be possible to get some integration tests for this? Presumably, we could verify that when scaffolding a template with dependencies, using this flag allows the integration test to proceed without getting hung on the interactive prompt. |
bfd0fa8
to
f1674e9
Compare
f1674e9
to
e838622
Compare
Test results:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/integration_scaffold_test.go (1)
159-173
: Well-implemented integration test with comprehensive coverage.The test effectively validates the new
--no-dependency-prompt
flag functionality by:
- Verifying the command executes successfully
- Confirming dependency warning messages are suppressed (line 169)
- Checking that expected scaffolded files are created (lines 170-171)
- Validating the completion message appears (line 172)
The test follows Go testing best practices with proper use of
t.Parallel()
, appropriate assertions, and good error handling.Consider adding the
--non-interactive
flag for consistency with other tests in this file:-, stderr, err := helpers.RunTerragruntCommandWithOutput(t, fmt.Sprintf("terragrunt --working-dir %s scaffold --no-dependency-prompt %s --output-folder %s", tmpEnvPath, localBoilerplateModuleDir, outputFolder)) +, stderr, err := helpers.RunTerragruntCommandWithOutput(t, fmt.Sprintf("terragrunt --non-interactive --working-dir %s scaffold --no-dependency-prompt %s --output-folder %s", tmpEnvPath, localBoilerplateModuleDir, outputFolder))
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
cli/commands/scaffold/cli.go
(2 hunks)cli/commands/scaffold/scaffold.go
(1 hunks)cli/commands/scaffold/scaffold_test.go
(1 hunks)docs-starlight/src/content/docs/02-features/07-scaffold.md
(2 hunks)docs/_docs/02_features/07-scaffold.md
(2 hunks)options/options.go
(2 hunks)test/fixtures/scaffold/dependency-prompt-template/.boilerplate/boilerplate.yml
(1 hunks)test/fixtures/scaffold/dependency-prompt-template/leaf/terragrunt.hcl
(1 hunks)test/integration_scaffold_test.go
(2 hunks)
✅ Files skipped from review due to trivial changes (1)
- test/fixtures/scaffold/dependency-prompt-template/leaf/terragrunt.hcl
🚧 Files skipped from review as they are similar to previous changes (6)
- docs/_docs/02_features/07-scaffold.md
- docs-starlight/src/content/docs/02-features/07-scaffold.md
- cli/commands/scaffold/scaffold.go
- cli/commands/scaffold/scaffold_test.go
- cli/commands/scaffold/cli.go
- options/options.go
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go
Instructions used from:
Sources:
⚙️ CodeRabbit Configuration File
🧬 Code Graph Analysis (1)
test/integration_scaffold_test.go (2)
test/helpers/package.go (1)
RunTerragruntCommandWithOutput
(935-939)util/file.go (1)
FileExists
(58-61)
🪛 YAMLlint (1.37.1)
test/fixtures/scaffold/dependency-prompt-template/.boilerplate/boilerplate.yml
[error] 7-7: trailing spaces
(trailing-spaces)
🔇 Additional comments (1)
test/integration_scaffold_test.go (1)
22-22
: LGTM!The constant is appropriately named and follows the established naming pattern for test fixtures.
test/fixtures/scaffold/dependency-prompt-template/.boilerplate/boilerplate.yml
Outdated
Show resolved
Hide resolved
e838622
to
e41b8db
Compare
e41b8db
to
db98839
Compare
db98839
to
3e0a03e
Compare
3e0a03e
to
a5622c4
Compare
We've got some lint failures, but I'm willing to merge this, then correct afterwards if the tests pass. It's not worth blocking the PR. |
@yhakbar I see the lint errors, I can fix that, my bad. |
Don't bother. It'll just slow down the process of getting this release. We can fix it in another PR. |
Description
Fixes #4419.
This PR introduces the ability to use the
--no-dependency-prompt
flag which is available in the boilerplate package. Using this flag enables skipping the prompt always asking if the user wants to have the dependencies for base and leaf files included or not. For example, the following output:Will not be shown in the
terragrunt scaffold
command output when--no-dependency-prompt
option is set.TODOs
Release Notes (draft)
Updated
terragrunt scaffold
so the--no-dependency-prompt
flag can be used.Summary by CodeRabbit
Summary by CodeRabbit