Skip to content

Commit 9d2a1b8

Browse files
committed
Fix terragrunt CLI flag ordering and console command syntax
- Prepend --non-interactive before subcommand (global flag must come first) - Update console test to use 'run -- console' syntax
1 parent 3c75e4a commit 9d2a1b8

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

modules/terraform/cmd.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,18 @@ func GetCommonOptions(options *Options, args ...string) (*Options, []string) {
5454
options.TerraformBinary = DefaultExecutable
5555
}
5656

57+
if options.Parallelism > 0 && len(args) > 0 && collections.ListContains(commandsWithParallelism, args[0]) {
58+
args = append(args, fmt.Sprintf("--parallelism=%d", options.Parallelism))
59+
}
60+
5761
if options.TerraformBinary == TerragruntDefaultPath {
58-
args = append(args, "--non-interactive")
62+
// Prepend --non-interactive as a global flag (must come before subcommand)
63+
args = append([]string{"--non-interactive"}, args...)
5964

6065
// for newer Terragrunt version, setting simplified log formatting
6166
setTerragruntLogFormatting(options)
6267
}
6368

64-
if options.Parallelism > 0 && len(args) > 0 && collections.ListContains(commandsWithParallelism, args[0]) {
65-
args = append(args, fmt.Sprintf("--parallelism=%d", options.Parallelism))
66-
}
67-
6869
// if SshAgent is provided, override the local SSH agent with the socket of our in-process agent
6970
if options.SshAgent != nil {
7071
// Initialize EnvVars, if it hasn't been set yet

test/terragrunt_example_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestTerragruntConsole(t *testing.T) {
4242
// website::tag::6:: Clean up resources with "terragrunt destroy" at the end of the test.
4343
defer terraform.Destroy(t, terraformOptions)
4444

45-
// website::tag::4:: Run "terragrunt console".
46-
out := terraform.RunTerraformCommand(t, terraformOptions, "console")
45+
// website::tag::4:: Run "terragrunt run -- console".
46+
out := terraform.RunTerraformCommand(t, terraformOptions, "run", "--", "console")
4747
assert.Contains(t, out, `"local variable named mylocal"`)
4848
}

0 commit comments

Comments
 (0)