Skip to content

Commit 22b36c2

Browse files
yhakbardenis256
andauthored
chore: Dropping util.JoinPath (#5219)
* chore: Dropping `util.JoinPath` * failing tests fixes * chore: windows setup * chore: windows tests fixes * chore: windows tests fixes * chore: failing tests fixes --------- Co-authored-by: Denis O <[email protected]>
1 parent a0fd5b6 commit 22b36c2

File tree

79 files changed

+1025
-988
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1025
-988
lines changed

cli/app_test.go

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"github.com/gruntwork-io/terragrunt/pkg/log/format"
2727
"github.com/gruntwork-io/terragrunt/test/helpers/logger"
2828
"github.com/gruntwork-io/terragrunt/tf"
29-
"github.com/gruntwork-io/terragrunt/util"
3029
"github.com/stretchr/testify/assert"
3130
"github.com/stretchr/testify/require"
3231
)
@@ -54,23 +53,23 @@ func TestParseTerragruntOptionsFromArgs(t *testing.T) {
5453
}{
5554
{
5655
args: []string{"plan"},
57-
expectedOptions: mockOptions(t, util.JoinPath(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", false, false, defaultLogLevel, false),
56+
expectedOptions: mockOptions(t, filepath.Join(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", false, false, defaultLogLevel, false),
5857
},
5958

6059
{
6160
args: []string{"plan", "bar"},
62-
expectedOptions: mockOptions(t, util.JoinPath(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan", "bar"}, false, "", false, false, defaultLogLevel, false),
61+
expectedOptions: mockOptions(t, filepath.Join(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan", "bar"}, false, "", false, false, defaultLogLevel, false),
6362
},
6463

6564
{
6665
args: []string{"--foo", "--bar"},
67-
expectedOptions: mockOptions(t, util.JoinPath(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"-foo", "-bar"}, false, "", false, false, defaultLogLevel, false),
66+
expectedOptions: mockOptions(t, filepath.Join(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"-foo", "-bar"}, false, "", false, false, defaultLogLevel, false),
6867
expectedErr: clipkg.UndefinedFlagError("foo"),
6968
},
7069

7170
{
7271
args: []string{"--foo", "apply", "--bar"},
73-
expectedOptions: mockOptions(t, util.JoinPath(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"apply", "-foo", "-bar"}, false, "", false, false, defaultLogLevel, false),
72+
expectedOptions: mockOptions(t, filepath.Join(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"apply", "-foo", "-bar"}, false, "", false, false, defaultLogLevel, false),
7473
expectedErr: clipkg.UndefinedFlagError("foo"),
7574
},
7675

@@ -81,7 +80,7 @@ func TestParseTerragruntOptionsFromArgs(t *testing.T) {
8180

8281
{
8382
args: []string{"apply", doubleDashed(shared.QueueIncludeExternalFlagName)},
84-
expectedOptions: mockOptions(t, util.JoinPath(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"apply"}, false, "", false, true, defaultLogLevel, false),
83+
expectedOptions: mockOptions(t, filepath.Join(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"apply"}, false, "", false, true, defaultLogLevel, false),
8584
},
8685

8786
{
@@ -91,47 +90,47 @@ func TestParseTerragruntOptionsFromArgs(t *testing.T) {
9190

9291
{
9392
args: []string{"plan", doubleDashed(global.WorkingDirFlagName), "/some/path"},
94-
expectedOptions: mockOptions(t, util.JoinPath("/some/path", config.DefaultTerragruntConfigPath), "/some/path", []string{"plan"}, false, "", false, false, defaultLogLevel, false),
93+
expectedOptions: mockOptions(t, filepath.Join("/some/path", config.DefaultTerragruntConfigPath), "/some/path", []string{"plan"}, false, "", false, false, defaultLogLevel, false),
9594
},
9695

9796
{
9897
args: []string{"plan", doubleDashed(run.SourceFlagName), "/some/path"},
99-
expectedOptions: mockOptions(t, util.JoinPath(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "/some/path", false, false, defaultLogLevel, false),
98+
expectedOptions: mockOptions(t, filepath.Join(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "/some/path", false, false, defaultLogLevel, false),
10099
},
101100

102101
{
103102
args: []string{"plan", doubleDashed(run.SourceMapFlagName), "git::[email protected]:one/gw-terraform-aws-vpc.git=git::[email protected]:two/test.git?ref=FEATURE"},
104-
expectedOptions: mockOptionsWithSourceMap(t, util.JoinPath(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, map[string]string{"git::[email protected]:one/gw-terraform-aws-vpc.git": "git::[email protected]:two/test.git?ref=FEATURE"}),
103+
expectedOptions: mockOptionsWithSourceMap(t, filepath.Join(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, map[string]string{"git::[email protected]:one/gw-terraform-aws-vpc.git": "git::[email protected]:two/test.git?ref=FEATURE"}),
105104
},
106105

107106
{
108107
args: []string{"plan", doubleDashed(shared.QueueIgnoreErrorsFlagName)},
109-
expectedOptions: mockOptions(t, util.JoinPath(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", true, false, defaultLogLevel, false),
108+
expectedOptions: mockOptions(t, filepath.Join(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", true, false, defaultLogLevel, false),
110109
},
111110

112111
{
113112
args: []string{"plan", doubleDashed(shared.QueueExcludeExternalFlagName)},
114-
expectedOptions: mockOptions(t, util.JoinPath(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", false, false, defaultLogLevel, false),
113+
expectedOptions: mockOptions(t, filepath.Join(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", false, false, defaultLogLevel, false),
115114
},
116115

117116
{
118117
args: []string{"plan", doubleDashed(run.IAMAssumeRoleFlagName), "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME"},
119-
expectedOptions: mockOptionsWithIamRole(t, util.JoinPath(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", false, "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME"),
118+
expectedOptions: mockOptionsWithIamRole(t, filepath.Join(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", false, "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME"),
120119
},
121120

122121
{
123122
args: []string{"plan", doubleDashed(run.IAMAssumeRoleDurationFlagName), "36000"},
124-
expectedOptions: mockOptionsWithIamAssumeRoleDuration(t, util.JoinPath(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", false, 36000),
123+
expectedOptions: mockOptionsWithIamAssumeRoleDuration(t, filepath.Join(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", false, 36000),
125124
},
126125

127126
{
128127
args: []string{"plan", doubleDashed(run.IAMAssumeRoleSessionNameFlagName), "terragrunt-iam-role-session-name"},
129-
expectedOptions: mockOptionsWithIamAssumeRoleSessionName(t, util.JoinPath(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", false, "terragrunt-iam-role-session-name"),
128+
expectedOptions: mockOptionsWithIamAssumeRoleSessionName(t, filepath.Join(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", false, "terragrunt-iam-role-session-name"),
130129
},
131130

132131
{
133132
args: []string{"plan", doubleDashed(run.IAMAssumeRoleWebIdentityTokenFlagName), "web-identity-token"},
134-
expectedOptions: mockOptionsWithIamWebIdentityToken(t, util.JoinPath(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", false, "web-identity-token"),
133+
expectedOptions: mockOptionsWithIamWebIdentityToken(t, filepath.Join(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", false, "web-identity-token"),
135134
},
136135

137136
{
@@ -147,7 +146,7 @@ func TestParseTerragruntOptionsFromArgs(t *testing.T) {
147146
// Adding the --terragrunt-log-level flag should result in DebugLevel configured
148147
{
149148
args: []string{"plan", doubleDashed(global.LogLevelFlagName), "debug"},
150-
expectedOptions: mockOptions(t, util.JoinPath(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", false, false, log.DebugLevel, false),
149+
expectedOptions: mockOptions(t, filepath.Join(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", false, false, log.DebugLevel, false),
151150
},
152151
{
153152
args: []string{"plan", doubleDashed(run.ConfigFlagName)},
@@ -165,7 +164,7 @@ func TestParseTerragruntOptionsFromArgs(t *testing.T) {
165164
},
166165
{
167166
args: []string{"plan", doubleDashed(run.InputsDebugFlagName)},
168-
expectedOptions: mockOptions(t, util.JoinPath(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", false, false, defaultLogLevel, true),
167+
expectedOptions: mockOptions(t, filepath.Join(workingDir, config.DefaultTerragruntConfigPath), workingDir, []string{"plan"}, false, "", false, false, defaultLogLevel, true),
169168
},
170169
}
171170

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func findAllTerraformFilesInModules(opts *options.TerragruntOptions) ([]string,
8888
// API, so the way we parse/read this modules.json file may break in future Terraform versions. Note that we
8989
// can't use the official HashiCorp code to parse this file, as it's marked internal:
9090
// https://github.com/hashicorp/terraform/blob/master/internal/modsdir/manifest.go
91-
modulesJSONPath := util.JoinPath(opts.DataDir(), "modules", "modules.json")
91+
modulesJSONPath := filepath.Join(opts.DataDir(), "modules", "modules.json")
9292

9393
if !util.FileExists(modulesJSONPath) {
9494
return nil, nil
@@ -110,7 +110,7 @@ func findAllTerraformFilesInModules(opts *options.TerragruntOptions) ([]string,
110110
if module.Key != "" && module.Dir != "" {
111111
moduleAbsPath := module.Dir
112112
if !filepath.IsAbs(moduleAbsPath) {
113-
moduleAbsPath = util.JoinPath(opts.WorkingDir, moduleAbsPath)
113+
moduleAbsPath = filepath.Join(opts.WorkingDir, moduleAbsPath)
114114
}
115115

116116
moduleFiles, err := util.FindTFFiles(moduleAbsPath)

cli/commands/commands.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ func initialSetup(cliCtx *cli.Context, l log.Logger, opts *options.TerragruntOpt
332332

333333
// --- Download Dir
334334
if opts.DownloadDir == "" {
335-
opts.DownloadDir = util.JoinPath(opts.WorkingDir, util.TerragruntCacheDir)
335+
opts.DownloadDir = filepath.Join(opts.WorkingDir, util.TerragruntCacheDir)
336336
}
337337

338338
downloadDir, err := filepath.Abs(opts.DownloadDir)
@@ -347,7 +347,7 @@ func initialSetup(cliCtx *cli.Context, l log.Logger, opts *options.TerragruntOpt
347347
opts.TerragruntConfigPath = config.GetDefaultConfigPath(opts.WorkingDir)
348348
} else if !filepath.IsAbs(opts.TerragruntConfigPath) &&
349349
(cliCtx.Command.Name == runcmd.CommandName || slices.Contains(tf.CommandNames, cliCtx.Command.Name)) {
350-
opts.TerragruntConfigPath = util.JoinPath(opts.WorkingDir, opts.TerragruntConfigPath)
350+
opts.TerragruntConfigPath = filepath.Join(opts.WorkingDir, opts.TerragruntConfigPath)
351351
}
352352

353353
opts.TerragruntConfigPath, err = filepath.Abs(opts.TerragruntConfigPath)

cli/commands/hcl/format/format.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func Run(ctx context.Context, l log.Logger, opts *options.TerragruntOptions) err
5454

5555
if targetFile != "" {
5656
if !filepath.IsAbs(targetFile) {
57-
targetFile = util.JoinPath(workingDir, targetFile)
57+
targetFile = filepath.Join(workingDir, targetFile)
5858
}
5959

6060
l.Debugf("Formatting hcl file at: %s.", targetFile)

cli/commands/scaffold/scaffold.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ func applyCatalogConfigToScaffold(ctx context.Context, l log.Logger, opts *optio
281281
func generateDefaultTemplate(boilerplateDir string) (string, error) {
282282
const ownerWriteGlobalReadPerms = 0644
283283
if err := os.WriteFile(
284-
util.JoinPath(
284+
filepath.Join(
285285
boilerplateDir,
286286
config.DefaultTerragruntConfigPath,
287287
),
@@ -292,7 +292,7 @@ func generateDefaultTemplate(boilerplateDir string) (string, error) {
292292
}
293293

294294
if err := os.WriteFile(
295-
util.JoinPath(
295+
filepath.Join(
296296
boilerplateDir,
297297
"boilerplate.yml",
298298
),
@@ -370,7 +370,7 @@ func prepareBoilerplateFiles(
370370
templateURL,
371371
tempDir string,
372372
) (string, error) {
373-
boilerplateDir := util.JoinPath(tempDir, util.DefaultBoilerplateDir)
373+
boilerplateDir := filepath.Join(tempDir, util.DefaultBoilerplateDir)
374374

375375
// process template url if it was passed. This overrides the .boilerplate folder in the OpenTofu/Terraform module
376376
if templateURL != "" {

0 commit comments

Comments
 (0)