Skip to content

Conversation

@yhakbar
Copy link
Collaborator

@yhakbar yhakbar commented Aug 12, 2025

Description

Fixes #4597.

TODOs

Read the Gruntwork contribution guidelines.

  • I authored this code entirely myself
  • I am submitting code based on open source software (e.g. MIT, MPL-2.0, Apache)]
  • I am adding or upgrading a dependency or adapted code and confirm it has a compatible open source license
  • Update the docs.
  • Run the relevant tests successfully, including pre-commit checks.
  • Include release notes. If this PR is backward incompatible, include a migration guide.

Release Notes (draft)

Removed support for legacy --terragrunt- prefixed flags. Only modern flag names are supported going forward.

For more information, see the migration guide.

Migration Guide

Summary by CodeRabbit

  • Refactor
    • Deprecation warnings unified to trigger via environment variables (not CLI flag-name aliases) across commands and global options; flag behavior unchanged.
  • Bug Fixes
    • Telemetry env vars accept both correct and previously misspelled keys for compatibility.
  • Chores
    • Standardized deprecation messaging for many options (auto-init/retry/approve, tfpath, downloads, output/metadata).
    • Tests and examples updated to use current standard CLI flags instead of legacy terragrunt-prefixed names; provider constraint loosened in a test fixture.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 12, 2025

📝 Walkthrough

Walkthrough

Deprecation wiring was changed from CLI flag-name based to environment-variable based across many CLI flag definitions; tests and calls updated to use public flag constants and standard flags; a strict control gained a Completed status. No public API signatures were changed.

Changes

Cohort / File(s) Summary
AWS Provider Patch CLI
cli/commands/aws-provider-patch/cli.go
Replace WithDeprecatedName for override-attr with WithDeprecatedEnvVars; deprecate env-var alias instead of CLI flag name.
HCL Format Flags
cli/commands/hcl/format/cli.go
For hclfmt flags (file, exclude-dir, check, diff, stdin) switch deprecations from flag-name to env-var based; add both TG_ and TERRAGRUNT_ env var deprecations.
HCL Validate Flags
cli/commands/hcl/validate/cli.go
Shift deprecations for strict, show-config-path, and json from flag-name to env-var based; add TG_ and TERRAGRUNT_ env var deprecations.
Render Flags
cli/commands/render/cli.go
Move deprecations for out, with-metadata, and disable-dependent-modules from flag-name to env-var based; expand TERRAGRUNT_ env var deprecations.
Run Flags (Broad Deprecation Refactor)
cli/commands/run/flags.go
Large-scale replacement of WithDeprecatedName(s) with WithDeprecatedEnvVars; consolidate multiple env vars with append(...); introduce WithDeprecatedFlag for some bool flags; remove unused strconv import.
Global Flags and Telemetry
cli/flags/global/flags.go
Convert global flag deprecations from flag-name to env-var based; remove nested deprecated flags under log format; add env-var deprecations for telemetry flags including misspelled variants.
Strict Controls Status
internal/strict/controls/controls.go
Add Status: strict.CompletedStatus to TerragruntPrefixFlags control literal.
Tests and Fixtures
cli/app_test.go, test/*.go, test/fixtures/.../main.tf
Update tests to use public flag constants and non-terragrunt- prefixed flags; adjust test invocations to run subcommand and change provider version constraint in fixture.

Sequence Diagram(s)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Assessment against linked issues

Objective Addressed Explanation
Remove legacy terragrunt- flags (all flags starting with terragrunt-) [#4597] Changes convert deprecation metadata to env-vars but do not remove terragrunt- legacy flags or their usage signatures.

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Add Completed status to TerragruntPrefixFlags control (internal/strict/controls/controls.go) This control-status change is unrelated to removing legacy terragrunt- flags and touches strict control metadata rather than flag removal.
Change provider constraint in fixture (test/fixtures/destroy-order/hello/main.tf) Updating the provider version constraint in test fixtures is unrelated to legacy flag removal objectives.

Possibly related PRs

Suggested reviewers

  • levkohimins
  • denis256
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/remove-legacy-terragrunt-flags

🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@vercel
Copy link

vercel bot commented Aug 12, 2025

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

Project Deployment Preview Comments Updated (UTC)
terragrunt-docs Ready Preview Comment Aug 12, 2025 8:36pm

@yhakbar yhakbar changed the title Chore/remove legacy terragrunt flags chore: Remove legacy terragrunt flags Aug 12, 2025
@yhakbar yhakbar marked this pull request as ready for review August 12, 2025 14:37
@yhakbar yhakbar marked this pull request as draft August 12, 2025 14:39
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)
cli/flags/global/flags.go (1)

222-226: Complex flag deprecation wrapper structure

The deprecation approach for the NonInteractive flag combines both environment variable and nested flag deprecations. The nested flag sets Negative: true and uses environment variables rather than a flag name, which could be confusing for maintainers.

Consider adding a comment to explain why this flag uses a different deprecation pattern:

 		},
 			flags.WithDeprecatedEnvVars(terragruntPrefix.EnvVars(DeprecatedNonInteractiveFlagName), terragruntPrefixControl),
+			// The tf-input flag is inverted (negative) compared to non-interactive
 			flags.WithDeprecatedFlag(&cli.BoolFlag{
 				Negative: true,
 				EnvVars:  flags.Prefix{}.EnvVars(DeprecatedTFInputFlagName),
 			}, nil, terragruntPrefixControl)),
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b006906 and 9f09b2e.

📒 Files selected for processing (7)
  • cli/commands/aws-provider-patch/cli.go (1 hunks)
  • cli/commands/hcl/format/cli.go (5 hunks)
  • cli/commands/hcl/validate/cli.go (3 hunks)
  • cli/commands/render/cli.go (3 hunks)
  • cli/commands/run/flags.go (16 hunks)
  • cli/flags/global/flags.go (11 hunks)
  • internal/strict/controls/controls.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go

⚙️ CodeRabbit Configuration File

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.

Files:

  • internal/strict/controls/controls.go
  • cli/commands/aws-provider-patch/cli.go
  • cli/commands/render/cli.go
  • cli/flags/global/flags.go
  • cli/commands/hcl/format/cli.go
  • cli/commands/hcl/validate/cli.go
  • cli/commands/run/flags.go
🧠 Learnings (3)
📚 Learning: 2025-04-17T13:02:28.098Z
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.

Applied to files:

  • cli/commands/aws-provider-patch/cli.go
  • cli/commands/render/cli.go
  • cli/flags/global/flags.go
  • cli/commands/hcl/format/cli.go
  • cli/commands/hcl/validate/cli.go
  • cli/commands/run/flags.go
📚 Learning: 2025-02-10T13:36:19.542Z
Learnt from: levkohimins
PR: gruntwork-io/terragrunt#3723
File: cli/commands/stack/action.go:160-160
Timestamp: 2025-02-10T13:36:19.542Z
Learning: The project uses a custom error package `github.com/gruntwork-io/terragrunt/internal/errors` which provides similar functionality to `fmt.Errorf` but includes stack traces. Prefer using this package's error functions (e.g., `errors.Errorf`, `errors.New`) over the standard library's error handling.

Applied to files:

  • cli/commands/run/flags.go
📚 Learning: 2025-03-06T23:44:09.413Z
Learnt from: partcyborg
PR: gruntwork-io/terragrunt#3974
File: config/config_partial.go:448-456
Timestamp: 2025-03-06T23:44:09.413Z
Learning: The TerragruntConfig struct in config/config.go does contain an Engine field that's used to store engine configuration data.

Applied to files:

  • cli/commands/run/flags.go
🧬 Code Graph Analysis (7)
internal/strict/controls/controls.go (1)
internal/strict/status.go (1)
  • CompletedStatus (9-9)
cli/commands/aws-provider-patch/cli.go (1)
cli/flags/flag_opts.go (1)
  • WithDeprecatedEnvVars (156-167)
cli/commands/render/cli.go (1)
cli/flags/flag_opts.go (1)
  • WithDeprecatedEnvVars (156-167)
cli/flags/global/flags.go (4)
cli/flags/flag_opts.go (1)
  • WithDeprecatedEnvVars (156-167)
cli/flags/flag.go (1)
  • NewFlag (28-41)
internal/cli/bool_flag.go (1)
  • BoolFlag (13-49)
internal/cli/generic_flag.go (1)
  • GenericFlag (19-48)
cli/commands/hcl/format/cli.go (1)
cli/flags/flag_opts.go (1)
  • WithDeprecatedEnvVars (156-167)
cli/commands/hcl/validate/cli.go (1)
cli/flags/flag_opts.go (1)
  • WithDeprecatedEnvVars (156-167)
cli/commands/run/flags.go (5)
cli/flags/flag_opts.go (1)
  • WithDeprecatedEnvVars (156-167)
cli/flags/flag.go (1)
  • NewFlag (28-41)
internal/cli/generic_flag.go (1)
  • GenericFlag (19-48)
internal/cli/bool_flag.go (1)
  • BoolFlag (13-49)
internal/cli/slice_flag.go (1)
  • SliceFlag (23-58)
⏰ 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). (2)
  • GitHub Check: Build (darwin/amd64)
  • GitHub Check: Build (linux/386)
🔇 Additional comments (20)
internal/strict/controls/controls.go (1)

166-166: LGTM! Status correctly reflects completed migration.

The addition of Status: strict.CompletedStatus to the TerragruntPrefixFlags control aligns with the PR objective of removing legacy --terragrunt- prefixed flags. This status change correctly indicates that the migration away from these deprecated flags has been completed.

cli/commands/aws-provider-patch/cli.go (1)

61-61: LGTM! Deprecation migration correctly implemented.

The change from WithDeprecatedName to WithDeprecatedEnvVars properly shifts the deprecation handling from flag-name-based to environment-variable-based, targeting the TERRAGRUNT_OVERRIDE_ATTR environment variable. This aligns with the broader PR objective of removing legacy --terragrunt- prefixed flags.

cli/commands/hcl/format/cli.go (5)

36-36: LGTM! Environment variable deprecation correctly added.

The addition of WithDeprecatedEnvVars(terragruntPrefix.EnvVars("hclfmt-file"), terragruntPrefixControl) properly deprecates the TERRAGRUNT_HCLFMT_FILE environment variable while maintaining the existing TG_HCLFMT_FILE deprecation.


46-46: LGTM! Environment variable deprecation correctly added.

The addition properly deprecates the TERRAGRUNT_HCLFMT_EXCLUDE_DIR environment variable while maintaining backward compatibility.


56-56: LGTM! Environment variable deprecation correctly added.

The addition properly deprecates the TERRAGRUNT_CHECK environment variable while maintaining backward compatibility.


66-66: LGTM! Environment variable deprecation correctly added.

The addition properly deprecates the TERRAGRUNT_DIFF environment variable while maintaining backward compatibility.


76-76: LGTM! Environment variable deprecation correctly added.

The addition properly deprecates the TERRAGRUNT_HCLFMT_STDIN environment variable while maintaining backward compatibility.

cli/commands/render/cli.go (3)

89-89: LGTM! Environment variable deprecation correctly added.

The addition of WithDeprecatedEnvVars(terragruntPrefix.EnvVars("json-out"), terragruntPrefixControl) properly deprecates the TERRAGRUNT_JSON_OUT environment variable while maintaining the existing TG_RENDER_JSON_OUT deprecation.


99-99: LGTM! Environment variable deprecation correctly added.

The addition properly deprecates the TERRAGRUNT_WITH_METADATA environment variable while maintaining backward compatibility.


109-109: LGTM! Environment variable deprecation correctly added.

The addition properly deprecates the TERRAGRUNT_JSON_DISABLE_DEPENDENT_MODULES environment variable while maintaining backward compatibility.

cli/commands/hcl/validate/cli.go (3)

38-38: LGTM! Environment variable deprecation correctly added.

The addition of WithDeprecatedEnvVars(terragruntPrefix.EnvVars("strict-validate"), terragruntPrefixControl) properly deprecates the TERRAGRUNT_STRICT_VALIDATE environment variable while maintaining existing TG_* deprecations.


55-55: LGTM! Environment variable deprecation correctly added.

The addition properly deprecates the TERRAGRUNT_HCLVALIDATE_SHOW_CONFIG_PATH environment variable while maintaining backward compatibility.


65-65: LGTM! Environment variable deprecation correctly added.

The addition properly deprecates the TERRAGRUNT_HCLVALIDATE_JSON environment variable while maintaining backward compatibility.

cli/flags/global/flags.go (2)

307-309: Preserving the typo for backward compatibility

The environment variable deprecation includes both the correctly spelled ("telemetry-trace-exporter") and misspelled ("telemerty-trace-exporter") variants, which is appropriate for backward compatibility. This pattern is consistently applied across all telemetry-related flags.


143-226: Consistent migration from flag-based to env-var-based deprecations

All deprecated flags in the global flags file have been successfully migrated from WithDeprecatedNames/WithDeprecatedName to WithDeprecatedEnvVars. The changes are consistent and align with the PR's objective to remove legacy --terragrunt- prefixed flags.

cli/commands/run/flags.go (5)

205-211: Correctly consolidating multiple deprecated environment variables

The implementation properly combines both "download" and "download-dir" environment variables into a single deprecation call, ensuring backward compatibility for both legacy names.


167-169: Nested deprecated flags using environment variables only

The deprecated flags for auto-init, auto-retry, and auto-approve now use EnvVars without Name fields. This is a valid pattern for environment-variable-only deprecations but differs from the typical flag deprecation approach.

Also applies to: 178-180, 189-191


379-381: Double deprecation for ForwardTFStdout flag

The flag has two WithDeprecatedEnvVars calls - one for "forward-tf-stdout" and another for "include-module-prefix" with legacyLogsControl. This suggests that "include-module-prefix" was an older name that's being deprecated alongside the general terragrunt prefix migration.


105-638: Comprehensive and consistent migration to env-var-based deprecations

All flags in the run command have been successfully migrated from flag-name-based deprecations to environment-variable-based deprecations. The changes are systematic and align with the PR objectives to remove legacy --terragrunt- prefixed flags. The implementation properly handles various deprecation patterns including single flags, multiple legacy names, and nested deprecations.


269-277: Verify deprecated IAM Web Identity Token env var precedence

The order of the envVars slice passed to WithDeprecatedEnvVars determines which deprecated environment variable is recognized first. In cli/commands/run/flags.go (lines 269–277), you’re appending:

  • iam-web-identity-token
  • iam-assume-role-web-identity-token

If your deprecation handler picks the first matching var, the more generic iam-web-identity-token will always take precedence over the more specific one. Please confirm that this matches the intended behavior—otherwise swap the append arguments so that iam-assume-role-web-identity-token comes first.

• File: cli/commands/run/flags.go
Lines: 269–277
Snippet:

flags.WithDeprecatedEnvVars(
  append(
    terragruntPrefix.EnvVars("iam-web-identity-token"),
    terragruntPrefix.EnvVars("iam-assume-role-web-identity-token")...,
  ),
  terragruntPrefixControl,
),

@yhakbar yhakbar marked this pull request as ready for review August 13, 2025 02:38
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: 2

🧹 Nitpick comments (2)
test/fixtures/destroy-order/hello/main.tf (1)

7-7: Stabilize provider version to avoid flaky tests

Using a broad lower-bound constraint can introduce nondeterminism as new major releases of hashicorp/null ship. Consider pinning or upper-bounding to keep fixtures stable across time and CI environments.

Apply this change to add an upper bound:

-      version = ">= 3.0.0"
+      version = ">= 3.0.0, < 4.0.0"

If you prefer maximal determinism, pin to the exact version used in other fixtures instead.

test/integration_regressions_test.go (1)

96-99: Assert against stderr instead of err.Error for stability.

RunTerragruntCommandWithOutput returns stderr; asserting on that is more robust than matching the error string (which can include wrappers and change formatting).

-	_, _, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt plan --non-interactive --working-dir "+rootPath)
+	_, stderr, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt plan --non-interactive --working-dir "+rootPath)
 	require.Error(t, err)
-	assert.Contains(t, err.Error(), "include blocks without label")
+	assert.Contains(t, stderr, "include blocks without label")
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9f09b2e and d2d4c58.

📒 Files selected for processing (8)
  • cli/app_test.go (4 hunks)
  • cli/commands/render/cli.go (3 hunks)
  • test/fixtures/destroy-order/hello/main.tf (1 hunks)
  • test/integration_debug_test.go (3 hunks)
  • test/integration_deprecated_test.go (4 hunks)
  • test/integration_regressions_test.go (1 hunks)
  • test/integration_runner_pool_test.go (1 hunks)
  • test/integration_test.go (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • cli/commands/render/cli.go
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go

⚙️ CodeRabbit Configuration File

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.

Files:

  • test/integration_regressions_test.go
  • test/integration_runner_pool_test.go
  • test/integration_debug_test.go
  • test/integration_deprecated_test.go
  • cli/app_test.go
  • test/integration_test.go
🧠 Learnings (1)
📚 Learning: 2025-04-17T13:02:28.098Z
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.

Applied to files:

  • test/integration_deprecated_test.go
  • cli/app_test.go
🧬 Code Graph Analysis (5)
test/integration_regressions_test.go (1)
test/helpers/package.go (1)
  • RunTerragruntCommandWithOutput (935-939)
test/integration_debug_test.go (1)
test/helpers/package.go (1)
  • RunTerragruntValidateInputs (968-990)
test/integration_deprecated_test.go (1)
test/helpers/package.go (2)
  • RunTerragruntCommandWithOutput (935-939)
  • RunTerragrunt (907-911)
cli/app_test.go (3)
cli/commands/run/flags.go (4)
  • QueueIncludeExternalFlagName (64-64)
  • QueueExcludeExternalFlagName (60-60)
  • IAMAssumeRoleFlagName (51-51)
  • IAMAssumeRoleWebIdentityTokenFlagName (54-54)
config/config.go (1)
  • DefaultTerragruntConfigPath (47-47)
cli/commands/aws-provider-patch/cli.go (1)
  • OverrideAttrFlagName (46-46)
test/integration_test.go (2)
test/helpers/package.go (1)
  • RunTerragruntCommandWithOutputWithContext (923-933)
util/file.go (1)
  • JoinPath (481-483)
⏰ 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). (1)
  • GitHub Check: Pull Request has non-contributor approval
🔇 Additional comments (17)
cli/app_test.go (6)

80-80: Correct migration from legacy flag naming system to modern flag constants.

The replacement of terragruntPrefix.FlagName(run.QueueIncludeExternalFlagName) with run.QueueIncludeExternalFlagName correctly aligns with the PR objective to remove legacy --terragrunt- prefixed flags.


110-110: Correct migration from legacy flag naming system to modern flag constants.

The replacement of terragruntPrefix.FlagName(run.QueueExcludeExternalFlagName) with run.QueueExcludeExternalFlagName correctly aligns with the PR objective to remove legacy --terragrunt- prefixed flags.


115-115: Correct migration from legacy flag naming system to modern flag constants.

The replacement of terragruntPrefix.FlagName(run.IAMAssumeRoleFlagName) with run.IAMAssumeRoleFlagName correctly aligns with the PR objective to remove legacy --terragrunt- prefixed flags.


130-130: Correct migration from legacy flag naming system to modern flag constants.

The replacement of terragruntPrefix.FlagName(run.IAMAssumeRoleWebIdentityTokenFlagName) with run.IAMAssumeRoleWebIdentityTokenFlagName correctly aligns with the PR objective to remove legacy --terragrunt- prefixed flags.


383-383: Correct migration from legacy flag naming system to modern flag constants.

The replacement of terragruntPrefix.FlagName(awsproviderpatch.OverrideAttrFlagName) with awsproviderpatch.OverrideAttrFlagName correctly aligns with the PR objective to remove legacy --terragrunt- prefixed flags.


469-482: No changes needed: legacy flag removal test is correct

The assertions in cli/app_test.go (lines 469–482) correctly use
terragruntPrefix.FlagName(awsproviderpatch.OverrideAttrFlagName)
to generate --terragrunt-override-attr and verify it does not appear in the help output for --help, -help, and -h. Verified that flags.Prefix.FlagName produces the expected flag string and there are no stray legacy flag definitions.

test/integration_deprecated_test.go (3)

32-32: LGTM: Updated flags on deprecated hclvalidate invocation

Switch to modern flags (--working-dir, --json, --show-config-path) while intentionally exercising the deprecated single-word command looks correct and keeps the test focused on the command alias.


71-71: LGTM: Pass-through subcommand coverage preserved

Using the modern global flags with the passthrough terraform subcommand scenarios maintains intent and test robustness.


114-114: LGTM: render-json test uses modern flags

Using --with-metadata and --json-out on the deprecated render-json command keeps the test aligned with the new flag semantics.

test/integration_debug_test.go (3)

106-108: Align all tests on --strict (one remaining uses --strict-validate)

Good switch to --strict here. There’s still a use of --strict-validate in TestTerragruntValidateInputsWithStrictMode (Lines ~134-137). For consistency with the CLI redesign, update that to --strict as well.

Do you want me to submit a follow-up patch updating that test case too?


151-152: LGTM: Strict mode behavior covered with unused var

The transition to --strict aligns with the new flag and keeps the negative test meaningful.


163-164: LGTM: Strict mode behavior covered with unused inputs

Modern flag usage looks correct; scenario remains valid.

test/integration_test.go (3)

234-235: LGTM: Switched to run-based CLI for detailed exit code flow

The new invocation style preserves the detailed-exitcode behavior while aligning with the modern run CLI.


255-257: LGTM: Consistent plan invocation post-apply

Using run --all with plan -detailed-exitcode keeps the semantics intact under the new CLI.


276-278: LGTM: No-changes path updated to modern CLI

The updated invocation is correct; assertions remain meaningful.

test/integration_regressions_test.go (2)

96-96: Modern flags usage LGTM.

Switching to --non-interactive and --working-dir aligns with the removal of legacy --terragrunt-* flags and the migration guide.


96-96: Remove all remaining legacy --terragrunt- flags
I still see numerous occurrences of deprecated CLI flags and aliases that need to be updated or removed per the PR objective.

Please address the following locations (non-exhaustive list):

  • Code handling deprecated flags:
    • tflint/tflint.go:28
    • internal/strict/controls/deprecated_flag_name.go (lines 44, 71)
    • config/config_helpers.go (lines 357, 361)
    • config/config.go (lines 988, 995)
    • cli/app.go (lines 130–131)
  • Tests exercising legacy flags:
    • config/config_helpers_test.go (params using --terragrunt-quiet, --terragrunt-global-cache)
    • cli/app_test.go:144
  • Documentation and migration guides (all references to --terragrunt-*):
    • docs-starlight/src/content/docs/**
    • docs/_docs/06_migration_guides/**
    • docs/_docs/04_reference/02-cli-options.md (many CLI Arg Alias entries)
    • Other .md/.mdx files under docs/_docs and docs-starlight

Ensure each deprecated flag:

  • Is removed from usage examples and fixtures
  • Updating docs to reference the new flags (e.g. --non-interactive, run --all)
  • Cleaning up any parsing logic or aliases that no longer need to exist
⛔ Skipped due to learnings
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.

stderr := bytes.Buffer{}

err := helpers.RunTerragruntCommand(t, "terragrunt terragrunt-info --terragrunt-non-interactive --terragrunt-working-dir "+testPath, &stdout, &stderr)
err := helpers.RunTerragruntCommand(t, "terragrunt terragrunt-info --non-interactive --working-dir "+testPath, &stdout, &stderr)
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Confirm ongoing support of 'terragrunt-info' alias, and consider adding a new-CLI companion test

This test intentionally validates the legacy 'terragrunt-info' alias. Given this PR removes legacy terragrunt- prefixed flags (not commands), ensure the alias remains supported; consider adding a companion test that uses the modern 'info print' path to guard both behaviors.

You can verify usages across the repo and confirm both forms are present with:


🏁 Script executed:

#!/bin/bash
rg -n $'^\\s*terragrunt\\s+terragrunt-info\\b' -A2 -S
rg -n $'^\\s*terragrunt\\s+info\\s+print\\b' -A2 -S

Length of output: 441


Add companion integration test for the modern info print CLI

The existing test in test/integration_deprecated_test.go at line 97 validates the legacy alias (terragrunt terragrunt-info), which remains supported (confirmed in docs/_docs/04_reference/02-cli-options.md). To ensure we guard the new syntax as well, add a companion test immediately after the current one:

 testPath := filepath.Join("fixtures", "deprecated", "simple")
 
-   err := helpers.RunTerragruntCommand(t, "terragrunt terragrunt-info --non-interactive --working-dir "+testPath, &stdout, &stderr)
+   // Legacy alias
+   err := helpers.RunTerragruntCommand(t, "terragrunt terragrunt-info --non-interactive --working-dir "+testPath, &stdout, &stderr)
+   require.NoError(t, err)
+
+   // Modern syntax
+   err = helpers.RunTerragruntCommand(t, "terragrunt info print --non-interactive --working-dir "+testPath, &stdout, &stderr)
+   require.NoError(t, err)

This will validate both the old alias and the new info print command path.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
err := helpers.RunTerragruntCommand(t, "terragrunt terragrunt-info --non-interactive --working-dir "+testPath, &stdout, &stderr)
testPath := filepath.Join("fixtures", "deprecated", "simple")
// Legacy alias
err := helpers.RunTerragruntCommand(t, "terragrunt terragrunt-info --non-interactive --working-dir "+testPath, &stdout, &stderr)
require.NoError(t, err)
// Modern syntax
err = helpers.RunTerragruntCommand(t, "terragrunt info print --non-interactive --working-dir "+testPath, &stdout, &stderr)
require.NoError(t, err)
🤖 Prompt for AI Agents
In test/integration_deprecated_test.go around line 97, add a companion
integration test immediately after the existing legacy check that runs the
modern CLI form; duplicate the existing call to helpers.RunTerragruntCommand but
replace the command string "terragrunt terragrunt-info --non-interactive
--working-dir "+testPath with "terragrunt info print --non-interactive
--working-dir "+testPath, wiring the same stdout/stderr variables and the same
assertions so the new syntax is exercised and validated alongside the legacy
alias.

var destroyOrder []string
re := regexp.MustCompile(`Hello, Module ([A-Za-z]+)`)
for _, line := range strings.Split(stdout, "\n") {
for line := range strings.SplitSeq(stdout, "\n") {
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

strings.SplitSeq requires a recent Go toolchain; verify go.mod/go version in CI

The streaming approach with strings.SplitSeq is a nice memory improvement, but it depends on newer Go (range-over-func additions). Please confirm the repo’s go.mod and CI use a Go version that provides strings.SplitSeq.

Run this to confirm the Go version and surface all usages:

If older Go versions must be supported, a safe fallback is bufio.Scanner:

scanner := bufio.NewScanner(strings.NewReader(stdout))
for scanner.Scan() {
  line := scanner.Text()
  // existing logic
}
require.NoError(t, scanner.Err())

🏁 Script executed:

#!/bin/bash
echo "go.mod version:" 
rg -n '^go\\s+\\d+\\.\\d+' go.mod

echo
echo "Occurrences of strings.SplitSeq:"
rg -n 'strings\\.SplitSeq\\(' -A2

Length of output: 288


I couldn’t detect the Go version or any occurrences because of a regex escape issue. Let’s re-run with simpler patterns:


🏁 Script executed:

#!/bin/bash
set -e

echo "go.mod version:"
# Match the 'go X.Y' directive
grep -E '^go [0-9]+\.[0-9]+' go.mod || echo "No go version directive found in go.mod"

echo
echo "Occurrences of strings.SplitSeq:"
# Look for any use of strings.SplitSeq(
rg -n 'strings\.SplitSeq\(' --color=never || echo "No occurrences of strings.SplitSeq found"

Length of output: 1671


We need to confirm that CI is using Go 1.24+ (which includes strings.SplitSeq). Let’s check your GitHub Actions (or other CI) setup for the Go version:


🏁 Script executed:

#!/bin/bash
set -e

echo "Workflow files:"
find .github/workflows -maxdepth 1 -type f -name '*.yml' -print || echo "No workflows found"

echo
echo "Looking for actions/setup-go usage and go-version in workflows:"
rg -n 'uses:\s*actions/setup-go' -A2 .github/workflows || echo "No setup-go steps detected"
rg -n 'go-version:' -A1 .github/workflows || echo "No go-version fields detected"

echo
echo "Checking other common CI files for Go version:"
for file in .travis.yml azure-pipelines.yml circle.yml; do
  if [ -f "$file" ]; then
    echo "In $file:"
    rg -n 'go_version|go-version|go:' -A1 "$file" || echo "  No Go version directive in $file"
  fi
done

Length of output: 1415


Pin Go Version in CI Workflows
go.mod already targets Go 1.24.4 (which includes strings.SplitSeq) and you’re using SplitSeq in many places (tests and code). However, I didn’t find any explicit Go setup (actions/setup-go or Docker container) in your .github/workflows/*.yml, so CI may be running on an older Go toolchain that lacks SplitSeq support.

• Add a “Set up Go” step in each workflow, for example:

- name: Set up Go
  uses: actions/setup-go@v4
  with:
    go-version: '1.24'

• If you must support Go < 1.21, swap the SplitSeq loops for a bufio.Scanner fallback:

scanner := bufio.NewScanner(strings.NewReader(stdout))
for scanner.Scan() {
  line := scanner.Text()
  // …
}
require.NoError(t, scanner.Err())
🤖 Prompt for AI Agents
In test/integration_runner_pool_test.go around line 70, the test uses
strings.SplitSeq(stdout, "\n") which requires Go 1.24+; update your CI workflows
to explicitly set up Go 1.24 (e.g. add an actions/setup-go@v4 step with
go-version: '1.24') so SplitSeq is available, or if you must support older Go
toolchains change the test to use a bufio.Scanner over strings.NewReader(stdout)
and iterate scanner.Text() with a final check for scanner.Err() instead of
SplitSeq.

@denis256
Copy link
Member

Noticed references for --terragrunt- in code:

cli/app.go:130:// removeNoColorFlagDuplicates removes one of the `--no-color` or `--terragrunt-no-color` arguments if both are present.
cli/app.go:131:// We have to do this because `--terragrunt-no-color` is a deprecated alias for `--no-color`,
internal/strict/controls/deprecated_flag_name.go:44:		// The global `--terragrunt-no-auto-init` flag has moved to the `run` command and will not be accessible as a global flag in a future version of Terragrunt. Use `run --no-auto-init` instead.
internal/strict/controls/deprecated_flag_name.go:71:		// The `--terragrunt-working-dir` flag is deprecated and will be removed in a future version of Terragrunt. Use `--working-dir=./test/fixtures/extra-args/` instead.
config/config.go:988:// adjustSourceWithMap implements the --terragrunt-source-map feature. This function will check if the URL portion of a
config/config.go:995://	--terragrunt-source-map git::ssh://[email protected]/gruntwork-io/i-dont-exist.git=/path/to/local-modules

@yhakbar
Copy link
Collaborator Author

yhakbar commented Aug 14, 2025

Noticed references for --terragrunt- in code:

cli/app.go:130:// removeNoColorFlagDuplicates removes one of the `--no-color` or `--terragrunt-no-color` arguments if both are present.
cli/app.go:131:// We have to do this because `--terragrunt-no-color` is a deprecated alias for `--no-color`,
internal/strict/controls/deprecated_flag_name.go:44:		// The global `--terragrunt-no-auto-init` flag has moved to the `run` command and will not be accessible as a global flag in a future version of Terragrunt. Use `run --no-auto-init` instead.
internal/strict/controls/deprecated_flag_name.go:71:		// The `--terragrunt-working-dir` flag is deprecated and will be removed in a future version of Terragrunt. Use `--working-dir=./test/fixtures/extra-args/` instead.
config/config.go:988:// adjustSourceWithMap implements the --terragrunt-source-map feature. This function will check if the URL portion of a
config/config.go:995://	--terragrunt-source-map git::ssh://[email protected]/gruntwork-io/i-dont-exist.git=/path/to/local-modules

We're deferring updates to comments to a future PR.

Negative: true,
Destination: &opts.AutoInit,
},
flags.WithDeprecatedNames(terragruntPrefix.FlagNames("no-auto-init"), terragruntPrefixControl),
Copy link
Contributor

Choose a reason for hiding this comment

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

should we include no-auto-init, no-auto-retry and no-auto-approve in the #4671 table?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will add after we merge that one

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.

Removal of legacy Terragrunt flags (all flags that start with terragrunt-)

4 participants