Skip to content

Commit 2717472

Browse files
authored
chore: Remove legacy terragrunt flags (#4650)
* fix: Removing support for legacy `--terragrunt` flags * chore: Removal of legacy `--terragrunt-` flags * fix: Fixing `TestParseMutliStringKeyValueArg` * fix: Fixing `TestParseTerragruntOptionsFromArgs` * fix: Fixing `TestDetailedExitCodeFailOnFirstRun` * fix: Fixing `TestDetailedExitCodeNoChanges` * fix: Fixing `TestDetailedExitCodeChangesPresentOne` * fix: Fixing `TestIncludeError` * fix: Fixing `TestRenderJSONConfigWithIncludesDependenciesAndLocals` * fix: Add `--json-out` flag back to avoid breaking `render-json` command * fix: Fixing more tests * fix: Fixing `TestRunnerPoolTerragruntDestroyOrder`
1 parent 1b96081 commit 2717472

File tree

14 files changed

+113
-141
lines changed

14 files changed

+113
-141
lines changed

cli/app_test.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ func TestParseTerragruntOptionsFromArgs(t *testing.T) {
3737
t.Skip("Skipping test on Windows")
3838
}
3939

40-
terragruntPrefix := flags.Prefix{flags.TerragruntPrefix}
41-
4240
workingDir, err := os.Getwd()
4341
if err != nil {
4442
t.Fatal(err)
@@ -79,7 +77,7 @@ func TestParseTerragruntOptionsFromArgs(t *testing.T) {
7977
},
8078

8179
{
82-
args: []string{"apply", doubleDashed(terragruntPrefix.FlagName("include-external-dependencies"))},
80+
args: []string{"apply", doubleDashed(run.QueueIncludeExternalFlagName)},
8381
expectedOptions: mockOptions(t, util.JoinPath(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"apply"}, false, "", false, true, defaultLogLevel, false),
8482
},
8583

@@ -109,12 +107,12 @@ func TestParseTerragruntOptionsFromArgs(t *testing.T) {
109107
},
110108

111109
{
112-
args: []string{"plan", doubleDashed(terragruntPrefix.FlagName("ignore-external-dependencies"))},
110+
args: []string{"plan", doubleDashed(run.QueueExcludeExternalFlagName)},
113111
expectedOptions: mockOptions(t, util.JoinPath(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", false, false, defaultLogLevel, false),
114112
},
115113

116114
{
117-
args: []string{"plan", doubleDashed(terragruntPrefix.FlagName("iam-role")), "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME"},
115+
args: []string{"plan", doubleDashed(run.IAMAssumeRoleFlagName), "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME"},
118116
expectedOptions: mockOptionsWithIamRole(t, util.JoinPath(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", false, "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME"),
119117
},
120118

@@ -129,7 +127,7 @@ func TestParseTerragruntOptionsFromArgs(t *testing.T) {
129127
},
130128

131129
{
132-
args: []string{"plan", doubleDashed(terragruntPrefix.FlagName("iam-web-identity-token")), "web-identity-token"},
130+
args: []string{"plan", doubleDashed(run.IAMAssumeRoleWebIdentityTokenFlagName), "web-identity-token"},
133131
expectedOptions: mockOptionsWithIamWebIdentityToken(t, util.JoinPath(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", false, "web-identity-token"),
134132
},
135133

@@ -382,9 +380,7 @@ func TestParseMultiStringArg(t *testing.T) {
382380
func TestParseMutliStringKeyValueArg(t *testing.T) {
383381
t.Parallel()
384382

385-
terragruntPrefix := flags.Prefix{flags.TerragruntPrefix}
386-
387-
flagName := doubleDashed(terragruntPrefix.FlagName(awsproviderpatch.OverrideAttrFlagName))
383+
flagName := doubleDashed(awsproviderpatch.OverrideAttrFlagName)
388384

389385
testCases := []struct {
390386
expectedErr error

cli/commands/aws-provider-patch/cli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func NewFlags(l log.Logger, opts *options.TerragruntOptions, prefix flags.Prefix
5858
Destination: &opts.AwsProviderPatchOverrides,
5959
Usage: "A key=value attribute to override in a provider block as part of the aws-provider-patch command. May be specified multiple times.",
6060
},
61-
flags.WithDeprecatedName(terragruntPrefix.FlagName("override-attr"), terragruntPrefixControl)),
61+
flags.WithDeprecatedEnvVars(terragruntPrefix.EnvVars("override-attr"), terragruntPrefixControl)),
6262
}
6363
}
6464

cli/commands/hcl/format/cli.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func NewFlags(opts *options.TerragruntOptions, prefix flags.Prefix) cli.Flags {
3333
Usage: "The path to a single HCL file that the command should run on.",
3434
},
3535
flags.WithDeprecatedEnvVars(tgPrefix.EnvVars("hclfmt-file"), terragruntPrefixControl), // `TG_HCLFMT_FILE`
36-
flags.WithDeprecatedNames(terragruntPrefix.FlagNames("hclfmt-file"), terragruntPrefixControl), // `--terragrunt-hclfmt-file`, `TERRAGRUNT_HCLFMT_FILE`
36+
flags.WithDeprecatedEnvVars(terragruntPrefix.EnvVars("hclfmt-file"), terragruntPrefixControl), // `TERRAGRUNT_HCLFMT_FILE`
3737
),
3838

3939
flags.NewFlag(&cli.SliceFlag[string]{
@@ -43,7 +43,7 @@ func NewFlags(opts *options.TerragruntOptions, prefix flags.Prefix) cli.Flags {
4343
Usage: "Skip HCL formatting in given directories.",
4444
},
4545
flags.WithDeprecatedEnvVars(tgPrefix.EnvVars("hclfmt-exclude-dir"), terragruntPrefixControl), // `TG_HCLFMT_EXCLUDE_DIR`
46-
flags.WithDeprecatedNames(terragruntPrefix.FlagNames("hclfmt-exclude-dir"), terragruntPrefixControl), // `--terragrunt-hclfmt-exclude-dir`, `TERRAGRUNT_EXCLUDE_DIR`
46+
flags.WithDeprecatedEnvVars(terragruntPrefix.EnvVars("hclfmt-exclude-dir"), terragruntPrefixControl), // `TERRAGRUNT_EXCLUDE_DIR`
4747
),
4848

4949
flags.NewFlag(&cli.BoolFlag{
@@ -53,7 +53,7 @@ func NewFlags(opts *options.TerragruntOptions, prefix flags.Prefix) cli.Flags {
5353
Usage: "Return a status code of zero when all files are formatted correctly, and a status code of one when they aren't.",
5454
},
5555
flags.WithDeprecatedEnvVars(tgPrefix.EnvVars("hclfmt-check"), terragruntPrefixControl), // `TG_HCLFMT_CHECK`
56-
flags.WithDeprecatedNames(terragruntPrefix.FlagNames("check"), terragruntPrefixControl), // `--terragrunt-check`, `TERRAGRUNT_CHECK`
56+
flags.WithDeprecatedEnvVars(terragruntPrefix.EnvVars("check"), terragruntPrefixControl), // `TERRAGRUNT_CHECK`
5757
),
5858

5959
flags.NewFlag(&cli.BoolFlag{
@@ -63,7 +63,7 @@ func NewFlags(opts *options.TerragruntOptions, prefix flags.Prefix) cli.Flags {
6363
Usage: "Print diff between original and modified file versions.",
6464
},
6565
flags.WithDeprecatedEnvVars(tgPrefix.EnvVars("hclfmt-diff"), terragruntPrefixControl), // `TG_HCLFMT_DIFF`
66-
flags.WithDeprecatedNames(terragruntPrefix.FlagNames("diff"), terragruntPrefixControl), // `--terragrunt-diff`, `TERRAGRUNT_DIFF`
66+
flags.WithDeprecatedEnvVars(terragruntPrefix.EnvVars("diff"), terragruntPrefixControl), // `TERRAGRUNT_DIFF`
6767
),
6868

6969
flags.NewFlag(&cli.BoolFlag{
@@ -73,7 +73,7 @@ func NewFlags(opts *options.TerragruntOptions, prefix flags.Prefix) cli.Flags {
7373
Usage: "Format HCL from stdin and print result to stdout.",
7474
},
7575
flags.WithDeprecatedEnvVars(tgPrefix.EnvVars("hclfmt-stdin"), terragruntPrefixControl), // `TG_HCLFMT_STDIN`
76-
flags.WithDeprecatedNames(terragruntPrefix.FlagNames("hclfmt-stdin"), terragruntPrefixControl), // `--terragrunt-hclfmt-stdin`, `TERRAGRUNT_HCLFMT_STDIN`
76+
flags.WithDeprecatedEnvVars(terragruntPrefix.EnvVars("hclfmt-stdin"), terragruntPrefixControl), // `TERRAGRUNT_HCLFMT_STDIN`
7777
),
7878
}
7979

cli/commands/hcl/validate/cli.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@ func NewFlags(opts *options.TerragruntOptions, prefix flags.Prefix) cli.Flags {
3131
Destination: &opts.HCLValidateStrict,
3232
Usage: "Enables strict mode. When used in combination with the `--inputs` flag, any inputs defined in Terragrunt that are _not_ used in OpenTofu/Terraform will trigger an error.",
3333
},
34-
flags.WithDeprecatedFlagName("strict-validate", terragruntPrefixControl), // `--strict-validate`
3534
flags.WithDeprecatedEnvVars(tgPrefix.EnvVars(
3635
"strict-validate", // `TG_STRICT_VALIDATE`
3736
"hclvalidate-strict-validate", // `TG_HCLVALIDATE_STRICT_VALIDATE`
3837
), terragruntPrefixControl),
39-
flags.WithDeprecatedNames(terragruntPrefix.FlagNames("strict-validate"), terragruntPrefixControl), // `--terragrunt-strict-validate`, `TERRAGRUNT_STRICT_VALIDATE`
38+
flags.WithDeprecatedEnvVars(terragruntPrefix.EnvVars("strict-validate"), terragruntPrefixControl), // `TERRAGRUNT_STRICT_VALIDATE`
4039
),
4140

4241
flags.NewFlag(&cli.BoolFlag{
@@ -53,7 +52,7 @@ func NewFlags(opts *options.TerragruntOptions, prefix flags.Prefix) cli.Flags {
5352
},
5453

5554
flags.WithDeprecatedEnvVars(tgPrefix.EnvVars("hclvalidate-strict-validate"), terragruntPrefixControl), // `TG_HCLVALIDATE_STRICT_VALIDATE`
56-
flags.WithDeprecatedNames(terragruntPrefix.FlagNames("hclvalidate-show-config-path"), terragruntPrefixControl), // `--terragrunt-hclvalidate-show-config-path`, `TERRAGRUNT_HCLVALIDATE_SHOW_CONFIG_PATH`
55+
flags.WithDeprecatedEnvVars(terragruntPrefix.EnvVars("hclvalidate-show-config-path"), terragruntPrefixControl), // `TERRAGRUNT_HCLVALIDATE_SHOW_CONFIG_PATH`
5756
),
5857

5958
flags.NewFlag(&cli.BoolFlag{
@@ -63,7 +62,7 @@ func NewFlags(opts *options.TerragruntOptions, prefix flags.Prefix) cli.Flags {
6362
Usage: "Format results in JSON format.",
6463
},
6564
flags.WithDeprecatedEnvVars(tgPrefix.EnvVars("hclvalidate-json"), terragruntPrefixControl), // `TG_HCLVALIDATE_JSON`
66-
flags.WithDeprecatedNames(terragruntPrefix.FlagNames("hclvalidate-json"), terragruntPrefixControl), // `--terragrunt-hclvalidate-json`, `TERRAGRUNT_HCLVALIDATE_JSON`
65+
flags.WithDeprecatedEnvVars(terragruntPrefix.EnvVars("hclvalidate-json"), terragruntPrefixControl), // `TERRAGRUNT_HCLVALIDATE_JSON`
6766
),
6867
}
6968

cli/commands/render/cli.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ func NewFlags(opts *Options, prefix flags.Prefix) cli.Flags {
8585
Destination: &opts.OutputPath,
8686
Usage: "The file name that terragrunt should use when rendering the terragrunt.hcl config (next to the unit configuration).",
8787
},
88-
flags.WithDeprecatedFlagName("json-out", terragruntPrefixControl), // `--json-out`
88+
flags.WithDeprecatedFlagName("json-out", terragruntPrefixControl), // `--json-out` (deprecated: use `--out` instead)
8989
flags.WithDeprecatedEnvVars(tgPrefix.EnvVars("render-json-out"), terragruntPrefixControl), // `TG_RENDER_JSON_OUT`
90-
flags.WithDeprecatedNames(terragruntPrefix.FlagNames("json-out"), terragruntPrefixControl), // `--terragrunt-json-out`, `TERRAGRUNT_JSON_OUT`
90+
flags.WithDeprecatedEnvVars(terragruntPrefix.EnvVars("json-out"), terragruntPrefixControl), // `TERRAGRUNT_JSON_OUT`
9191
),
9292

9393
flags.NewFlag(&cli.BoolFlag{
@@ -97,7 +97,7 @@ func NewFlags(opts *Options, prefix flags.Prefix) cli.Flags {
9797
Usage: "Add metadata to the rendered output file.",
9898
},
9999
flags.WithDeprecatedEnvVars(tgPrefix.EnvVars("render-json-with-metadata"), terragruntPrefixControl), // `TG_RENDER_JSON_WITH_METADATA`
100-
flags.WithDeprecatedNames(terragruntPrefix.FlagNames("with-metadata"), terragruntPrefixControl), // `--terragrunt-with-metadata`, `TERRAGRUNT_WITH_METADATA`
100+
flags.WithDeprecatedEnvVars(terragruntPrefix.EnvVars("with-metadata"), terragruntPrefixControl), // `TERRAGRUNT_WITH_METADATA`
101101
),
102102

103103
flags.NewFlag(&cli.BoolFlag{
@@ -107,7 +107,7 @@ func NewFlags(opts *Options, prefix flags.Prefix) cli.Flags {
107107
Usage: "Disable identification of dependent modules when rendering config.",
108108
},
109109
flags.WithDeprecatedEnvVars(tgPrefix.EnvVars("render-json-disable-dependent-modules"), terragruntPrefixControl), // `TG_RENDER_JSON_DISABLE_DEPENDENT_MODULES`
110-
flags.WithDeprecatedNames(terragruntPrefix.FlagNames("json-disable-dependent-modules"), terragruntPrefixControl), // `--terragrunt-json-disable-dependent-modules`, `TERRAGRUNT_JSON_DISABLE_DEPENDENT_MODULES`
110+
flags.WithDeprecatedEnvVars(terragruntPrefix.EnvVars("json-disable-dependent-modules"), terragruntPrefixControl), // `TERRAGRUNT_JSON_DISABLE_DEPENDENT_MODULES`
111111
),
112112
}
113113
}

0 commit comments

Comments
 (0)