Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package terragrunt for openSUSE:Factory checked in at 2023-10-05 20:03:40 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/terragrunt (Old) and /work/SRC/openSUSE:Factory/.terragrunt.new.28202 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "terragrunt" Thu Oct 5 20:03:40 2023 rev:70 rq:1115720 version:0.51.9 Changes: -------- --- /work/SRC/openSUSE:Factory/terragrunt/terragrunt.changes 2023-10-02 20:09:24.465151184 +0200 +++ /work/SRC/openSUSE:Factory/.terragrunt.new.28202/terragrunt.changes 2023-10-05 20:04:35.777841263 +0200 @@ -1,0 +2,15 @@ +Thu Oct 05 04:49:53 UTC 2023 - ka...@b1-systems.de + +- Update to version 0.51.9: + * Update render-json to include list of dependent modules (#2740) + * refactor: fix usage of deprecated calls to io/ioutil package + (#2742) + +------------------------------------------------------------------- +Wed Oct 04 09:37:21 UTC 2023 - ka...@b1-systems.de + +- Update to version 0.51.8: + * Add check for aws session before checking S3 bucket (#2739) + * docs: removes two errors in the markdown (#2741) + +------------------------------------------------------------------- Old: ---- terragrunt-0.51.7.obscpio New: ---- terragrunt-0.51.9.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ terragrunt.spec ++++++ --- /var/tmp/diff_new_pack.uTuA8A/_old 2023-10-05 20:04:37.461902103 +0200 +++ /var/tmp/diff_new_pack.uTuA8A/_new 2023-10-05 20:04:37.461902103 +0200 @@ -19,7 +19,7 @@ %define __arch_install_post export NO_BRP_STRIP_DEBUG=true Name: terragrunt -Version: 0.51.7 +Version: 0.51.9 Release: 0 Summary: Thin wrapper for Terraform for working with multiple Terraform modules License: MIT ++++++ _service ++++++ --- /var/tmp/diff_new_pack.uTuA8A/_old 2023-10-05 20:04:37.493903259 +0200 +++ /var/tmp/diff_new_pack.uTuA8A/_new 2023-10-05 20:04:37.493903259 +0200 @@ -3,7 +3,7 @@ <param name="url">https://github.com/gruntwork-io/terragrunt</param> <param name="scm">git</param> <param name="exclude">.git</param> - <param name="revision">v0.51.7</param> + <param name="revision">v0.51.9</param> <param name="versionformat">@PARENT_TAG@</param> <param name="changesgenerate">enable</param> <param name="versionrewrite-pattern">v(.*)</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.uTuA8A/_old 2023-10-05 20:04:37.513903982 +0200 +++ /var/tmp/diff_new_pack.uTuA8A/_new 2023-10-05 20:04:37.517904126 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/gruntwork-io/terragrunt</param> - <param name="changesrevision">7765fafc434af4089a388148ddfe27e62d35c40d</param></service></servicedata> + <param name="changesrevision">1a80dba8786bdca1e157530c153066e5cfdd4a52</param></service></servicedata> (No newline at EOF) ++++++ terragrunt-0.51.7.obscpio -> terragrunt-0.51.9.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/aws_helper/config.go new/terragrunt-0.51.9/aws_helper/config.go --- old/terragrunt-0.51.7/aws_helper/config.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/aws_helper/config.go 2023-10-04 20:33:53.000000000 +0200 @@ -217,6 +217,13 @@ return *identity, nil } +// ValidateAwsSession - Validate if current AWS session is valid +func ValidateAwsSession(config *AwsSessionConfig, terragruntOptions *options.TerragruntOptions) error { + // read the caller identity to check if the credentials are valid + _, err := GetAWSCallerIdentity(config, terragruntOptions) + return err +} + // Get the AWS Partition of the current session configuration func GetAWSPartition(config *AwsSessionConfig, terragruntOptions *options.TerragruntOptions) (string, error) { identity, err := GetAWSCallerIdentity(config, terragruntOptions) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/aws_helper/config_test.go new/terragrunt-0.51.9/aws_helper/config_test.go --- old/terragrunt-0.51.7/aws_helper/config_test.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/aws_helper/config_test.go 2023-10-04 20:33:53.000000000 +0200 @@ -28,3 +28,13 @@ assert.Contains(t, r.HTTPRequest.Header.Get("User-Agent"), "terragrunt") } + +func TestAwsSessionValidationFail(t *testing.T) { + t.Parallel() + + err := ValidateAwsSession(&AwsSessionConfig{ + Region: "not-existing-region", + CredsFilename: "/tmp/not-existing-file", + }, options.NewTerragruntOptions()) + assert.Error(t, err) +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/cli/commands/aws-provider-patch/action.go new/terragrunt-0.51.9/cli/commands/aws-provider-patch/action.go --- old/terragrunt-0.51.7/cli/commands/aws-provider-patch/action.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/cli/commands/aws-provider-patch/action.go 2023-10-04 20:33:53.000000000 +0200 @@ -31,7 +31,7 @@ import ( "encoding/json" "fmt" - "io/ioutil" + "os" "path/filepath" "strings" @@ -117,7 +117,7 @@ return nil, nil } - modulesJsonContents, err := ioutil.ReadFile(modulesJsonPath) + modulesJsonContents, err := os.ReadFile(modulesJsonPath) if err != nil { return nil, errors.WithStackTrace(err) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/cli/commands/hclfmt/action.go new/terragrunt-0.51.9/cli/commands/hclfmt/action.go --- old/terragrunt-0.51.7/cli/commands/hclfmt/action.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/cli/commands/hclfmt/action.go 2023-10-04 20:33:53.000000000 +0200 @@ -6,7 +6,6 @@ import ( "bytes" "fmt" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -115,7 +114,7 @@ if fileUpdated { opts.Logger.Infof("%s was updated", tgHclFile) - return ioutil.WriteFile(tgHclFile, newContents, info.Mode()) + return os.WriteFile(tgHclFile, newContents, info.Mode()) } return nil @@ -135,7 +134,7 @@ // bytesDiff uses GNU diff to display the differences between the contents of HCL file before and after formatting func bytesDiff(b1, b2 []byte, path string) ([]byte, error) { - f1, err := ioutil.TempFile("", "") + f1, err := os.CreateTemp("", "") if err != nil { return nil, err } @@ -144,7 +143,7 @@ os.Remove(f1.Name()) }() - f2, err := ioutil.TempFile("", "") + f2, err := os.CreateTemp("", "") if err != nil { return nil, err } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/cli/commands/hclfmt/action_test.go new/terragrunt-0.51.9/cli/commands/hclfmt/action_test.go --- old/terragrunt-0.51.7/cli/commands/hclfmt/action_test.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/cli/commands/hclfmt/action_test.go 2023-10-04 20:33:53.000000000 +0200 @@ -1,7 +1,6 @@ package hclfmt import ( - "io/ioutil" "os" "path/filepath" "testing" @@ -117,7 +116,7 @@ defer os.RemoveAll(tmpPath) require.NoError(t, err) - expected, err := ioutil.ReadFile("../../../test/fixture-hclfmt-check/expected.hcl") + expected, err := os.ReadFile("../../../test/fixture-hclfmt-check/expected.hcl") require.NoError(t, err) tgOptions, err := options.NewTerragruntOptionsForTest("") @@ -148,7 +147,7 @@ t.Parallel() tgHclPath := filepath.Join(tmpPath, dir) - actual, err := ioutil.ReadFile(tgHclPath) + actual, err := os.ReadFile(tgHclPath) require.NoError(t, err) assert.Equal(t, expected, actual) }) @@ -163,7 +162,7 @@ defer os.RemoveAll(tmpPath) require.NoError(t, err) - expected, err := ioutil.ReadFile("../../../test/fixture-hclfmt-check-errors/expected.hcl") + expected, err := os.ReadFile("../../../test/fixture-hclfmt-check-errors/expected.hcl") require.NoError(t, err) tgOptions, err := options.NewTerragruntOptionsForTest("") @@ -194,7 +193,7 @@ t.Parallel() tgHclPath := filepath.Join(tmpPath, dir) - actual, err := ioutil.ReadFile(tgHclPath) + actual, err := os.ReadFile(tgHclPath) require.NoError(t, err) assert.Equal(t, expected, actual) }) @@ -209,7 +208,7 @@ defer os.RemoveAll(tmpPath) require.NoError(t, err) - expected, err := ioutil.ReadFile("../../../test/fixture-hclfmt/expected.hcl") + expected, err := os.ReadFile("../../../test/fixture-hclfmt/expected.hcl") require.NoError(t, err) tgOptions, err := options.NewTerragruntOptionsForTest("") @@ -226,7 +225,7 @@ t.Run(tgOptions.HclFile, func(t *testing.T) { t.Parallel() tgHclPath := filepath.Join(tmpPath, tgOptions.HclFile) - formatted, err := ioutil.ReadFile(tgHclPath) + formatted, err := os.ReadFile(tgHclPath) require.NoError(t, err) assert.Equal(t, expected, formatted) }) @@ -237,7 +236,7 @@ "a/b/c/terragrunt.hcl", } - original, err := ioutil.ReadFile("../../../test/fixture-hclfmt/terragrunt.hcl") + original, err := os.ReadFile("../../../test/fixture-hclfmt/terragrunt.hcl") require.NoError(t, err) // test that none of the other files were formatted @@ -251,7 +250,7 @@ t.Run(dir, func(t *testing.T) { t.Parallel() testingPath := filepath.Join(tmpPath, dir) - actual, err := ioutil.ReadFile(testingPath) + actual, err := os.ReadFile(testingPath) require.NoError(t, err) assert.Equal(t, original, actual) }) @@ -266,7 +265,7 @@ defer os.RemoveAll(tmpPath) require.NoError(t, err) - expected, err := ioutil.ReadFile("../../../test/fixture-hclfmt-heredoc/expected.hcl") + expected, err := os.ReadFile("../../../test/fixture-hclfmt-heredoc/expected.hcl") require.NoError(t, err) tgOptions, err := options.NewTerragruntOptionsForTest("") @@ -278,7 +277,7 @@ require.NoError(t, err) tgHclPath := filepath.Join(tmpPath, "terragrunt.hcl") - actual, err := ioutil.ReadFile(tgHclPath) + actual, err := os.ReadFile(tgHclPath) require.NoError(t, err) assert.Equal(t, expected, actual) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/cli/commands/render-json/action.go new/terragrunt-0.51.9/cli/commands/render-json/action.go --- old/terragrunt-0.51.7/cli/commands/render-json/action.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/cli/commands/render-json/action.go 2023-10-04 20:33:53.000000000 +0200 @@ -9,9 +9,11 @@ import ( "encoding/json" "fmt" - "io/ioutil" + "os" "path/filepath" + "github.com/gruntwork-io/terragrunt/configstack" + "github.com/zclconf/go-cty/cty" ctyjson "github.com/zclconf/go-cty/cty/json" @@ -33,6 +35,15 @@ return fmt.Errorf("Terragrunt was not able to render the config as json because it received no config. This is almost certainly a bug in Terragrunt. Please open an issue on github.com/gruntwork-io/terragrunt with this message and the contents of your terragrunt.hcl.") } + dependentModules := configstack.FindWhereWorkingDirIsIncluded(opts, cfg) + var dependentModulesPath []*string + for _, module := range dependentModules { + dependentModulesPath = append(dependentModulesPath, &module.Path) + } + + cfg.DependentModulesPath = dependentModulesPath + cfg.SetFieldMetadata(config.MetadataDependentModules, map[string]interface{}{config.FoundInFile: opts.TerragruntConfigPath}) + var terragruntConfigCty cty.Value if opts.RenderJsonWithMetadata { @@ -64,7 +75,7 @@ } opts.Logger.Debugf("Rendering config %s to JSON %s", opts.TerragruntConfigPath, jsonOutPath) - if err := ioutil.WriteFile(jsonOutPath, jsonBytes, 0644); err != nil { + if err := os.WriteFile(jsonOutPath, jsonBytes, 0644); err != nil { return errors.WithStackTrace(err) } return nil diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/cli/commands/terraform/action_test.go new/terragrunt-0.51.9/cli/commands/terraform/action_test.go --- old/terragrunt-0.51.7/cli/commands/terraform/action_test.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/cli/commands/terraform/action_test.go 2023-10-04 20:33:53.000000000 +0200 @@ -2,7 +2,6 @@ import ( "fmt" - "io/ioutil" "os" "path/filepath" "testing" @@ -471,7 +470,7 @@ } func createTempFile(t *testing.T) string { - tmpFile, err := ioutil.TempFile("", "") + tmpFile, err := os.CreateTemp("", "") if err != nil { t.Fatalf("Failed to create temp directory: %s\n", err.Error()) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/cli/commands/terraform/debug.go new/terragrunt-0.51.9/cli/commands/terraform/debug.go --- old/terragrunt-0.51.7/cli/commands/terraform/debug.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/cli/commands/terraform/debug.go 2023-10-04 20:33:53.000000000 +0200 @@ -3,7 +3,6 @@ import ( "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -42,7 +41,7 @@ configFolder := filepath.Dir(terragruntOptions.TerragruntConfigPath) fileName := filepath.Join(configFolder, TerragruntTFVarsFile) - if err := ioutil.WriteFile(fileName, fileContents, os.FileMode(int(0600))); err != nil { + if err := os.WriteFile(fileName, fileContents, os.FileMode(int(0600))); err != nil { return errors.WithStackTrace(err) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/cli/commands/terraform/download_source_test.go new/terragrunt-0.51.9/cli/commands/terraform/download_source_test.go --- old/terragrunt-0.51.7/cli/commands/terraform/download_source_test.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/cli/commands/terraform/download_source_test.go 2023-10-04 20:33:53.000000000 +0200 @@ -2,7 +2,7 @@ import ( "fmt" - "io/ioutil" + "io" "net/url" "os" "path" @@ -360,7 +360,7 @@ func createConfig(t *testing.T, canonicalUrl string, downloadDir string, sourceUpdate bool) (*terraform.Source, *options.TerragruntOptions, *config.TerragruntConfig, error) { logger := logrus.New() - logger.Out = ioutil.Discard + logger.Out = io.Discard terraformSource := &terraform.Source{ CanonicalSourceURL: parseUrl(t, canonicalUrl), DownloadDir: downloadDir, @@ -389,7 +389,7 @@ func testAlreadyHaveLatestCode(t *testing.T, canonicalUrl string, downloadDir string, expected bool) { logger := logrus.New() - logger.Out = ioutil.Discard + logger.Out = io.Discard terraformSource := &terraform.Source{ CanonicalSourceURL: parseUrl(t, canonicalUrl), DownloadDir: downloadDir, @@ -407,7 +407,7 @@ } func tmpDir(t *testing.T) string { - dir, err := ioutil.TempDir("", "download-source-test") + dir, err := os.MkdirTemp("", "download-source-test") if err != nil { t.Fatal(err) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/cli/commands/terraform/version_check.go new/terragrunt-0.51.9/cli/commands/terraform/version_check.go --- old/terragrunt-0.51.7/cli/commands/terraform/version_check.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/cli/commands/terraform/version_check.go 2023-10-04 20:33:53.000000000 +0200 @@ -2,7 +2,7 @@ import ( "fmt" - "io/ioutil" + "io" "regexp" "strings" @@ -69,8 +69,8 @@ func PopulateTerraformVersion(terragruntOptions *options.TerragruntOptions) error { // Discard all log output to make sure we don't pollute stdout or stderr with this extra call to '--version' terragruntOptionsCopy := terragruntOptions.Clone(terragruntOptions.TerragruntConfigPath) - terragruntOptionsCopy.Writer = ioutil.Discard - terragruntOptionsCopy.ErrWriter = ioutil.Discard + terragruntOptionsCopy.Writer = io.Discard + terragruntOptionsCopy.ErrWriter = io.Discard // Remove any TF_CLI_ARGS before version checking. These are appended to // the arguments supplied on the command line and cause issues when running diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/cli/commands/validate-inputs/action.go new/terragrunt-0.51.9/cli/commands/validate-inputs/action.go --- old/terragrunt-0.51.7/cli/commands/validate-inputs/action.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/cli/commands/validate-inputs/action.go 2023-10-04 20:33:53.000000000 +0200 @@ -7,7 +7,7 @@ import ( "encoding/json" "fmt" - "io/ioutil" + "os" "path/filepath" "strings" @@ -266,7 +266,7 @@ // getVarNamesFromVarFile will parse the given terraform var file and return a list of names of variables that are // configured in that var file. func getVarNamesFromVarFile(varFile string) ([]string, error) { - fileContents, err := ioutil.ReadFile(varFile) + fileContents, err := os.ReadFile(varFile) if err != nil { return nil, err } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/codegen/generate.go new/terragrunt-0.51.9/codegen/generate.go --- old/terragrunt-0.51.7/codegen/generate.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/codegen/generate.go 2023-10-04 20:33:53.000000000 +0200 @@ -4,7 +4,6 @@ "bufio" "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "sort" @@ -91,7 +90,7 @@ } contentsToWrite := fmt.Sprintf("%s%s", prefix, config.Contents) - if err := ioutil.WriteFile(targetPath, []byte(contentsToWrite), 0644); err != nil { + if err := os.WriteFile(targetPath, []byte(contentsToWrite), 0644); err != nil { return errors.WithStackTrace(err) } terragruntOptions.Logger.Debugf("Generated file %s.", targetPath) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/config/config.go new/terragrunt-0.51.9/config/config.go --- old/terragrunt-0.51.7/config/config.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/config/config.go 2023-10-04 20:33:53.000000000 +0200 @@ -2,7 +2,6 @@ import ( "fmt" - "io/ioutil" "net/url" "os" "path" @@ -33,7 +32,7 @@ DefaultTerragruntJsonConfigPath = "terragrunt.hcl.json" ) -const foundInFile = "found_in_file" +const FoundInFile = "found_in_file" const ( MetadataTerraform = "terraform" @@ -55,6 +54,7 @@ MetadataRetryableErrors = "retryable_errors" MetadataRetryMaxAttempts = "retry_max_attempts" MetadataRetrySleepIntervalSec = "retry_sleep_interval_sec" + MetadataDependentModules = "dependent_modules" ) // Order matters, for example if none of the files are found `GetDefaultConfigPath` func returns the last element. @@ -95,6 +95,9 @@ // Map to store fields metadata FieldsMetadata map[string]map[string]interface{} + + // List of dependent modules + DependentModulesPath []*string } func (conf *TerragruntConfig) String() string { @@ -896,7 +899,7 @@ GenerateConfigs: map[string]codegen.GenerateConfig{}, } - defaultMetadata := map[string]interface{}{foundInFile: configPath} + defaultMetadata := map[string]interface{}{FoundInFile: configPath} if terragruntConfigFromFile.RemoteState != nil { remoteState, err := terragruntConfigFromFile.RemoteState.toConfig() if err != nil { @@ -1123,7 +1126,7 @@ // dependency or dependencies blocks defined. Note that this does not do any decoding of the blocks, as it is only meant // to check for block presence. func configFileHasDependencyBlock(configPath string, terragruntOptions *options.TerragruntOptions) (bool, error) { - configBytes, err := ioutil.ReadFile(configPath) + configBytes, err := os.ReadFile(configPath) if err != nil { return false, errors.WithStackTrace(err) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/config/config_as_cty.go new/terragrunt-0.51.9/config/config_as_cty.go --- old/terragrunt-0.51.7/config/config_as_cty.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/config/config_as_cty.go 2023-10-04 20:33:53.000000000 +0200 @@ -121,6 +121,16 @@ output[MetadataLocals] = localsCty } + if len(config.DependentModulesPath) > 0 { + dependentModulesCty, err := convertToCtyWithJson(config.DependentModulesPath) + if err != nil { + return cty.NilVal, err + } + if dependentModulesCty != cty.NilVal { + output[MetadataDependentModules] = dependentModulesCty + } + } + return convertValuesMapToCtyVal(output) } @@ -177,6 +187,10 @@ return cty.NilVal, err } + if err := wrapWithMetadata(config, config.DependentModulesPath, MetadataDependentModules, &output); err != nil { + return cty.NilVal, err + } + // Terraform terraformConfigCty, err := terraformConfigAsCty(config.Terraform) if err != nil { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/config/config_as_cty_test.go new/terragrunt-0.51.9/config/config_as_cty_test.go --- old/terragrunt-0.51.7/config/config_as_cty_test.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/config/config_as_cty_test.go 2023-10-04 20:33:53.000000000 +0200 @@ -21,6 +21,7 @@ testFalse := false mockOutputs := cty.Zero mockOutputsAllowedTerraformCommands := []string{"init"} + dependentModulesPath := []*string{&testSource} testConfig := TerragruntConfig{ Terraform: &TerraformConfig{ Source: &testSource, @@ -77,6 +78,7 @@ Locals: map[string]interface{}{ "quote": "the answer is 42", }, + DependentModulesPath: dependentModulesPath, TerragruntDependencies: []Dependency{ Dependency{ Name: "foo", @@ -221,6 +223,8 @@ return "retry_max_attempts", true case "RetrySleepIntervalSec": return "retry_sleep_interval_sec", true + case "DependentModulesPath": + return "dependent_modules", true default: t.Fatalf("Unknown struct property: %s", fieldName) // This should not execute diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/config/dependency.go new/terragrunt-0.51.9/config/dependency.go --- old/terragrunt-0.51.7/config/dependency.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/config/dependency.go 2023-10-04 20:33:53.000000000 +0200 @@ -6,7 +6,7 @@ "context" "encoding/json" "fmt" - "io/ioutil" + "io" "os" "path/filepath" "strings" @@ -702,7 +702,7 @@ if err := util.EnsureDirectory(terragruntOptions.DownloadDir); err != nil { return nil, err } - tempWorkDir, err := ioutil.TempDir(terragruntOptions.DownloadDir, "") + tempWorkDir, err := os.MkdirTemp(terragruntOptions.DownloadDir, "") if err != nil { return nil, err } @@ -798,7 +798,7 @@ } defer result.Body.Close() - steateBody, err := ioutil.ReadAll(result.Body) + steateBody, err := io.ReadAll(result.Body) if err != nil { return nil, err } @@ -820,11 +820,11 @@ func setupTerragruntOptionsForBareTerraform(originalOptions *options.TerragruntOptions, workingDir string, configPath string, iamRoleOpts options.IAMRoleOptions) (*options.TerragruntOptions, error) { // Here we clone the terragrunt options again since we need to make further modifications to it to allow running // terraform directly. - // Set the terraform working dir to the tempdir, and set stdout writer to ioutil.Discard so that output content is + // Set the terraform working dir to the tempdir, and set stdout writer to io.Discard so that output content is // not logged. targetTGOptions := cloneTerragruntOptionsForDependency(originalOptions, configPath) targetTGOptions.WorkingDir = workingDir - targetTGOptions.Writer = ioutil.Discard + targetTGOptions.Writer = io.Discard // If the target config has an IAM role directive and it was not set on the command line, set it to // the one we retrieved from the config. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/configstack/module.go new/terragrunt-0.51.9/configstack/module.go --- old/terragrunt-0.51.7/configstack/module.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/configstack/module.go 2023-10-04 20:33:53.000000000 +0200 @@ -3,6 +3,7 @@ import ( "encoding/json" "fmt" + "os" "path/filepath" "sort" "strings" @@ -536,9 +537,12 @@ var matchedModulesMap = make(map[string]*TerraformModule) gitTopLevelDir, err := shell.GitTopLevelDir(terragruntOptions, terragruntOptions.WorkingDir) - if err == nil { // top level detection worked - pathsToCheck = append(pathsToCheck, gitTopLevelDir) - } else { // detection failed, trying to use include directories as source for stacks + useIncludes := err != nil // fallback to includes git top level directory detection failed + if err == nil { + pathsToCheck, err = buildDirList(terragruntOptions, gitTopLevelDir) + useIncludes = err != nil // fallback to includes if directory list building failed + } + if useIncludes { // detection failed, trying to use include directories as source for stacks uniquePaths := make(map[string]bool) for _, includePath := range terragruntConfig.ProcessedIncludes { uniquePaths[filepath.Dir(includePath.Path)] = true @@ -549,28 +553,26 @@ } for _, dir := range pathsToCheck { // iterate over detected paths, build stacks and filter modules by working dir - dir = dir + filepath.FromSlash("/") + dir += filepath.FromSlash("/") cfgOptions, err := options.NewTerragruntOptionsWithConfigPath(dir) if err != nil { terragruntOptions.Logger.Debugf("Failed to build terragrunt options from %s %v", dir, err) - return nil + continue } cfgOptions.Env = terragruntOptions.Env cfgOptions.LogLevel = terragruntOptions.LogLevel cfgOptions.OriginalTerragruntConfigPath = terragruntOptions.OriginalTerragruntConfigPath - if terragruntOptions.TerraformCommand == "destroy" { - var hook = NewForceLogLevelHook(logrus.DebugLevel) - cfgOptions.Logger.Logger.AddHook(hook) - } + var hook = NewForceLogLevelHook(logrus.DebugLevel) + cfgOptions.Logger.Logger.AddHook(hook) stack, err := FindStackInSubfolders(cfgOptions, terragruntConfig) if err != nil { - // loggign error as debug since in some cases stack building may fail because parent files can be designed + // log error as debug since in some cases stack building may fail because parent files can be designed // to work with relative paths from downstream modules terragruntOptions.Logger.Debugf("Failed to build module stack %v", err) - return nil + continue } for _, module := range stack.Modules { @@ -632,3 +634,21 @@ } return []byte(""), nil } + +// buildDirList - build list of directories from working directory to git top level directory +func buildDirList(terragruntOptions *options.TerragruntOptions, topLevelDir string) ([]string, error) { + var pathsToCheck []string + relativePath, err := util.GetPathRelativeTo(topLevelDir, terragruntOptions.WorkingDir) + if err != nil { + return pathsToCheck, err + } + // build list of directories from working directory to git top level directory + // from which later will be built stacks + pathToAdd := terragruntOptions.WorkingDir + splits := strings.Split(relativePath, string(os.PathSeparator)) + for _, path := range splits { + pathToAdd = filepath.Join(pathToAdd, path) + pathsToCheck = append(pathsToCheck, pathToAdd) + } + return pathsToCheck, nil +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/configstack/stack_test.go new/terragrunt-0.51.9/configstack/stack_test.go --- old/terragrunt-0.51.7/configstack/stack_test.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/configstack/stack_test.go 2023-10-04 20:33:53.000000000 +0200 @@ -1,7 +1,6 @@ package configstack import ( - "io/ioutil" "os" "path/filepath" "strings" @@ -153,7 +152,7 @@ } func createTempFolder(t *testing.T) string { - tmpFolder, err := ioutil.TempDir("", "") + tmpFolder, err := os.MkdirTemp("", "") if err != nil { t.Fatalf("Failed to create temp directory: %s\n", err.Error()) } @@ -170,7 +169,7 @@ containingDir := filepath.Dir(absPath) createDirIfNotExist(t, containingDir) - err := ioutil.WriteFile(absPath, contents, os.ModePerm) + err := os.WriteFile(absPath, contents, os.ModePerm) if err != nil { t.Fatalf("Failed to write file at path %s: %s\n", path, err.Error()) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/remote/remote_state_s3.go new/terragrunt-0.51.9/remote/remote_state_s3.go --- old/terragrunt-0.51.7/remote/remote_state_s3.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/remote/remote_state_s3.go 2023-10-04 20:33:53.000000000 +0200 @@ -160,6 +160,11 @@ sessionConfig := s3ConfigExtended.GetAwsSessionConfig() + // Validate current AWS session before checking S3 + if err = aws_helper.ValidateAwsSession(sessionConfig, terragruntOptions); err != nil { + return false, err + } + s3Client, err := CreateS3Client(sessionConfig, terragruntOptions) if err != nil { return false, err diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/terraform/getter.go new/terragrunt-0.51.9/terraform/getter.go --- old/terragrunt-0.51.7/terraform/getter.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/terraform/getter.go 2023-10-04 20:33:53.000000000 +0200 @@ -4,7 +4,7 @@ "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "os" @@ -283,7 +283,7 @@ return nil, nil, errors.WithStackTrace(RegistryAPIErr{url: getURL.String(), statusCode: resp.StatusCode}) } - bodyData, err := ioutil.ReadAll(resp.Body) + bodyData, err := io.ReadAll(resp.Body) return bodyData, &resp.Header, errors.WithStackTrace(err) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/terraform/getter_test.go new/terragrunt-0.51.9/terraform/getter_test.go --- old/terragrunt-0.51.7/terraform/getter_test.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/terraform/getter_test.go 2023-10-04 20:33:53.000000000 +0200 @@ -2,7 +2,6 @@ import ( "context" - "io/ioutil" "net/url" "os" "path/filepath" @@ -105,7 +104,7 @@ testModuleURL, err := url.Parse("tfr://registry.terraform.io/terraform-aws-modules/vpc/aws?version=3.3.0") require.NoError(t, err) - dstPath, err := ioutil.TempDir("", "") + dstPath, err := os.MkdirTemp("", "") require.NoError(t, err) defer os.RemoveAll(dstPath) @@ -124,7 +123,7 @@ testModuleURL, err := url.Parse("tfr://registry.terraform.io/terraform-aws-modules/vpc/aws//modules/vpc-endpoints?version=3.3.0") require.NoError(t, err) - dstPath, err := ioutil.TempDir("", "") + dstPath, err := os.MkdirTemp("", "") require.NoError(t, err) defer os.RemoveAll(dstPath) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/terraform/source.go new/terragrunt-0.51.9/terraform/source.go --- old/terragrunt-0.51.7/terraform/source.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/terraform/source.go 2023-10-04 20:33:53.000000000 +0200 @@ -3,7 +3,6 @@ import ( "crypto/sha256" "fmt" - "io/ioutil" "net/url" "os" "path/filepath" @@ -107,7 +106,7 @@ } } - return errors.WithStackTrace(ioutil.WriteFile(terraformSource.VersionFile, []byte(version), 0640)) + return errors.WithStackTrace(os.WriteFile(terraformSource.VersionFile, []byte(version), 0640)) } // Take the given source path and create a Source struct from it, including the folder where the source should diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/test/fixture-destroy-warning/app/terragrunt.hcl new/terragrunt-0.51.9/test/fixture-destroy-warning/app/terragrunt.hcl --- old/terragrunt-0.51.7/test/fixture-destroy-warning/app/terragrunt.hcl 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/test/fixture-destroy-warning/app/terragrunt.hcl 1970-01-01 01:00:00.000000000 +0100 @@ -1,11 +0,0 @@ -dependency "vpc" { - config_path = "../vpc" - - mock_outputs = { - vpc = "mock" - } -} - -dependencies { - paths = ["../vpc"] -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/test/fixture-destroy-warning/app-v1/terragrunt.hcl new/terragrunt-0.51.9/test/fixture-destroy-warning/app-v1/terragrunt.hcl --- old/terragrunt-0.51.7/test/fixture-destroy-warning/app-v1/terragrunt.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.51.9/test/fixture-destroy-warning/app-v1/terragrunt.hcl 2023-10-04 20:33:53.000000000 +0200 @@ -0,0 +1,11 @@ +dependency "vpc" { + config_path = "../vpc" + + mock_outputs = { + vpc = "mock" + } +} + +dependencies { + paths = ["../vpc"] +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/test/fixture-destroy-warning/app-v2/terragrunt.hcl new/terragrunt-0.51.9/test/fixture-destroy-warning/app-v2/terragrunt.hcl --- old/terragrunt-0.51.7/test/fixture-destroy-warning/app-v2/terragrunt.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.51.9/test/fixture-destroy-warning/app-v2/terragrunt.hcl 2023-10-04 20:33:53.000000000 +0200 @@ -0,0 +1,11 @@ +dependency "vpc" { + config_path = "../vpc" + + mock_outputs = { + vpc = "mock" + } +} + +dependencies { + paths = ["../vpc"] +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/test/integration_debug_test.go new/terragrunt-0.51.9/test/integration_debug_test.go --- old/terragrunt-0.51.7/test/integration_debug_test.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/test/integration_debug_test.go 2023-10-04 20:33:53.000000000 +0200 @@ -4,7 +4,6 @@ "bytes" "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -72,7 +71,7 @@ validateInputs(t, outputs) // Also make sure the undefined variable is not included in the json file - debugJsonContents, err := ioutil.ReadFile(debugFile) + debugJsonContents, err := os.ReadFile(debugFile) require.NoError(t, err) var data map[string]interface{} require.NoError(t, json.Unmarshal(debugJsonContents, &data)) @@ -181,7 +180,7 @@ func TestRenderJSONConfig(t *testing.T) { t.Parallel() - tmpDir, err := ioutil.TempDir("", "terragrunt-render-json-*") + tmpDir, err := os.MkdirTemp("", "terragrunt-render-json-*") require.NoError(t, err) jsonOut := filepath.Join(tmpDir, "terragrunt_rendered.json") defer os.RemoveAll(tmpDir) @@ -192,7 +191,7 @@ runTerragrunt(t, fmt.Sprintf("terragrunt run-all apply -auto-approve --terragrunt-non-interactive --terragrunt-log-level debug --terragrunt-working-dir %s", fixtureRenderJSON)) runTerragrunt(t, fmt.Sprintf("terragrunt render-json --terragrunt-non-interactive --terragrunt-log-level debug --terragrunt-working-dir %s --terragrunt-json-out %s", fixtureRenderJSONMainModulePath, jsonOut)) - jsonBytes, err := ioutil.ReadFile(jsonOut) + jsonBytes, err := os.ReadFile(jsonOut) require.NoError(t, err) var rendered map[string]interface{} @@ -290,7 +289,7 @@ func TestRenderJSONConfigWithIncludesDependenciesAndLocals(t *testing.T) { t.Parallel() - tmpDir, err := ioutil.TempDir("", "terragrunt-render-json-*") + tmpDir, err := os.MkdirTemp("", "terragrunt-render-json-*") require.NoError(t, err) jsonOut := filepath.Join(tmpDir, "terragrunt_rendered.json") defer os.RemoveAll(tmpDir) @@ -302,7 +301,7 @@ runTerragrunt(t, fmt.Sprintf("terragrunt render-json --terragrunt-non-interactive --terragrunt-log-level debug --terragrunt-working-dir %s --terragrunt-json-out %s", workDir, jsonOut)) - jsonBytes, err := ioutil.ReadFile(jsonOut) + jsonBytes, err := os.ReadFile(jsonOut) require.NoError(t, err) var rendered map[string]interface{} @@ -403,7 +402,7 @@ runTerragrunt(t, fmt.Sprintf("terragrunt run-all render-json --terragrunt-non-interactive --terragrunt-log-level debug --terragrunt-working-dir %s", workDir)) - bazJSONBytes, err := ioutil.ReadFile(bazJSONOut) + bazJSONBytes, err := os.ReadFile(bazJSONOut) require.NoError(t, err) var bazRendered map[string]interface{} @@ -421,7 +420,7 @@ ) } - rootChildJSONBytes, err := ioutil.ReadFile(rootChildJSONOut) + rootChildJSONBytes, err := os.ReadFile(rootChildJSONOut) require.NoError(t, err) var rootChildRendered map[string]interface{} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/test/integration_download_test.go new/terragrunt-0.51.9/test/integration_download_test.go --- old/terragrunt-0.51.7/test/integration_download_test.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/test/integration_download_test.go 2023-10-04 20:33:53.000000000 +0200 @@ -3,7 +3,6 @@ import ( "bytes" "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -217,7 +216,7 @@ lockFilePath := util.JoinPath(result.WorkingDir, util.TerraformLockFile) require.FileExists(t, lockFilePath) - readFile, err := ioutil.ReadFile(lockFilePath) + readFile, err := os.ReadFile(lockFilePath) require.NoError(t, err) // In our lock file, we intentionally have hashes for an older version of the AWS provider. If the lock file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/test/integration_include_test.go new/terragrunt-0.51.9/test/integration_include_test.go --- old/terragrunt-0.51.7/test/integration_include_test.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/test/integration_include_test.go 2023-10-04 20:33:53.000000000 +0200 @@ -4,7 +4,7 @@ "bytes" "encoding/json" "fmt" - "io/ioutil" + "os" "path/filepath" "strings" "testing" @@ -30,7 +30,7 @@ func TestTerragruntWorksWithIncludeLocals(t *testing.T) { t.Parallel() - files, err := ioutil.ReadDir(includeExposeFixturePath) + files, err := os.ReadDir(includeExposeFixturePath) require.NoError(t, err) testCases := []string{} @@ -193,7 +193,7 @@ func TestTerragruntWorksWithMultipleInclude(t *testing.T) { t.Parallel() - files, err := ioutil.ReadDir(includeMultipleFixturePath) + files, err := os.ReadDir(includeMultipleFixturePath) require.NoError(t, err) testCases := []string{} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/test/integration_test.go new/terragrunt-0.51.9/test/integration_test.go --- old/terragrunt-0.51.7/test/integration_test.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/test/integration_test.go 2023-10-04 20:33:53.000000000 +0200 @@ -6,7 +6,6 @@ "encoding/json" "fmt" "io" - "io/ioutil" "math/rand" "net/url" "os" @@ -310,9 +309,9 @@ runTerragrunt(t, fmt.Sprintf("terragrunt run-all apply -auto-approve --terragrunt-log-level debug --terragrunt-non-interactive --terragrunt-working-dir %s", rootPath)) - _, beforeErr := ioutil.ReadFile(beforeOnlyPath + "/file.out") + _, beforeErr := os.ReadFile(beforeOnlyPath + "/file.out") assert.NoError(t, beforeErr) - _, afterErr := ioutil.ReadFile(afterOnlyPath + "/file.out") + _, afterErr := os.ReadFile(afterOnlyPath + "/file.out") assert.NoError(t, afterErr) } @@ -327,9 +326,9 @@ runTerragrunt(t, fmt.Sprintf("terragrunt apply-all -auto-approve --terragrunt-log-level debug --terragrunt-non-interactive --terragrunt-working-dir %s", rootPath)) - _, beforeErr := ioutil.ReadFile(beforeOnlyPath + "/file.out") + _, beforeErr := os.ReadFile(beforeOnlyPath + "/file.out") assert.NoError(t, beforeErr) - _, afterErr := ioutil.ReadFile(afterOnlyPath + "/file.out") + _, afterErr := os.ReadFile(afterOnlyPath + "/file.out") assert.NoError(t, afterErr) } @@ -342,7 +341,7 @@ runTerragrunt(t, fmt.Sprintf("terragrunt apply -auto-approve --terragrunt-non-interactive --terragrunt-working-dir %s", rootPath)) - _, exception := ioutil.ReadFile(rootPath + "/file.out") + _, exception := os.ReadFile(rootPath + "/file.out") assert.NoError(t, exception) } @@ -367,7 +366,7 @@ runTerragrunt(t, fmt.Sprintf("terragrunt apply -auto-approve --terragrunt-non-interactive --terragrunt-working-dir %s", rootPath)) - _, exception := ioutil.ReadFile(rootPath + "/file.out") + _, exception := os.ReadFile(rootPath + "/file.out") assert.NoError(t, exception) } @@ -383,8 +382,8 @@ stderr := bytes.Buffer{} err := runTerragruntCommand(t, fmt.Sprintf("terragrunt apply -auto-approve --terragrunt-non-interactive --terragrunt-working-dir %s", rootPath), &stdout, &stderr) - _, beforeException := ioutil.ReadFile(rootPath + "/before.out") - _, afterException := ioutil.ReadFile(rootPath + "/after.out") + _, beforeException := os.ReadFile(rootPath + "/before.out") + _, afterException := os.ReadFile(rootPath + "/after.out") output := stdout.String() @@ -418,14 +417,14 @@ err := runTerragruntCommand(t, fmt.Sprintf("terragrunt apply -auto-approve --terragrunt-non-interactive --terragrunt-config %s --terragrunt-working-dir %s", tmpTerragruntConfigPath, childPath), &stdout, &stderr) assert.ErrorContains(t, err, "executable file not found in $PATH") - _, beforeException := ioutil.ReadFile(childPath + "/before.out") - _, beforeChildException := ioutil.ReadFile(childPath + "/before-child.out") - _, beforeOverriddenParentException := ioutil.ReadFile(childPath + "/before-parent.out") - _, afterException := ioutil.ReadFile(childPath + "/after.out") - _, afterParentException := ioutil.ReadFile(childPath + "/after-parent.out") - _, errorHookParentException := ioutil.ReadFile(childPath + "/error-hook-parent.out") - _, errorHookChildException := ioutil.ReadFile(childPath + "/error-hook-child.out") - _, errorHookOverridenParentException := ioutil.ReadFile(childPath + "/error-hook-merge-parent.out") + _, beforeException := os.ReadFile(childPath + "/before.out") + _, beforeChildException := os.ReadFile(childPath + "/before-child.out") + _, beforeOverriddenParentException := os.ReadFile(childPath + "/before-parent.out") + _, afterException := os.ReadFile(childPath + "/after.out") + _, afterParentException := os.ReadFile(childPath + "/after-parent.out") + _, errorHookParentException := os.ReadFile(childPath + "/error-hook-parent.out") + _, errorHookChildException := os.ReadFile(childPath + "/error-hook-child.out") + _, errorHookOverridenParentException := os.ReadFile(childPath + "/error-hook-merge-parent.out") assert.NoError(t, beforeException) assert.NoError(t, beforeChildException) @@ -1004,7 +1003,7 @@ //fixtureApp := path.Join(TEST_FIXTURE_PARALLELISM, "app") // copy the template `numberOfModules` times into the app - tmpEnvPath, err := ioutil.TempDir("", "terragrunt-test") + tmpEnvPath, err := os.MkdirTemp("", "terragrunt-test") if err != nil { t.Fatalf("Failed to create temp dir due to error: %v", err) } @@ -1310,7 +1309,7 @@ // https://github.com/gruntwork-io/terragrunt/issues/1778 branchName = url.QueryEscape(branchName) mainContents = strings.Replace(mainContents, "__BRANCH_NAME__", branchName, -1) - require.NoError(t, ioutil.WriteFile(mainTFFile, []byte(mainContents), 0444)) + require.NoError(t, os.WriteFile(mainTFFile, []byte(mainContents), 0444)) assert.NoError( t, @@ -2744,7 +2743,7 @@ t, runTerragruntCommand(t, command, &stdout, &stderr), ) - expected, _ := ioutil.ReadFile(path) + expected, _ := os.ReadFile(path) require.Contains(t, string(expected), "local") // runs terragrunt again. All the outputs must be @@ -2754,7 +2753,7 @@ t, runTerragruntCommand(t, command, &stdout, &stderr), ) - actual, _ := ioutil.ReadFile(path) + actual, _ := os.ReadFile(path) require.Equal(t, expected, actual) } } @@ -4049,7 +4048,7 @@ } func copyEnvironment(t *testing.T, environmentPath string) string { - tmpDir, err := ioutil.TempDir("", "terragrunt-test") + tmpDir, err := os.MkdirTemp("", "terragrunt-test") if err != nil { t.Fatalf("Failed to create temp dir due to error: %v", err) } @@ -4062,7 +4061,7 @@ } func copyEnvironmentWithTflint(t *testing.T, environmentPath string) string { - tmpDir, err := ioutil.TempDir("", "terragrunt-test") + tmpDir, err := os.MkdirTemp("", "terragrunt-test") if err != nil { t.Fatalf("Failed to create temp dir due to error: %v", err) } @@ -4084,7 +4083,7 @@ } func createTmpTerragruntConfigWithParentAndChild(t *testing.T, parentPath string, childRelPath string, s3BucketName string, parentConfigFileName string, childConfigFileName string) string { - tmpDir, err := ioutil.TempDir("", "terragrunt-parent-child-test") + tmpDir, err := os.MkdirTemp("", "terragrunt-parent-child-test") if err != nil { t.Fatalf("Failed to create temp dir due to error: %v", err) } @@ -4107,7 +4106,7 @@ } func createTmpTerragruntConfig(t *testing.T, templatesPath string, s3BucketName string, lockTableName string, configFileName string) string { - tmpFolder, err := ioutil.TempDir("", "terragrunt-test") + tmpFolder, err := os.MkdirTemp("", "terragrunt-test") if err != nil { t.Fatalf("Failed to create temp folder due to error: %v", err) } @@ -4120,14 +4119,14 @@ } func createTmpTerragruntConfigContent(t *testing.T, contents string, configFileName string) string { - tmpFolder, err := ioutil.TempDir("", "terragrunt-test") + tmpFolder, err := os.MkdirTemp("", "terragrunt-test") if err != nil { t.Fatalf("Failed to create temp folder due to error: %v", err) } tmpTerragruntConfigFile := util.JoinPath(tmpFolder, configFileName) - if err := ioutil.WriteFile(tmpTerragruntConfigFile, []byte(contents), 0444); err != nil { + if err := os.WriteFile(tmpTerragruntConfigFile, []byte(contents), 0444); err != nil { t.Fatalf("Error writing temp Terragrunt config to %s: %v", tmpTerragruntConfigFile, err) } @@ -4135,7 +4134,7 @@ } func createTmpTerragruntGCSConfig(t *testing.T, templatesPath string, project string, location string, gcsBucketName string, configFileName string) string { - tmpFolder, err := ioutil.TempDir("", "terragrunt-test") + tmpFolder, err := os.MkdirTemp("", "terragrunt-test") if err != nil { t.Fatalf("Failed to create temp folder due to error: %v", err) } @@ -4158,7 +4157,7 @@ contents = strings.Replace(contents, "__FILL_IN_REGION__", region, -1) contents = strings.Replace(contents, "__FILL_IN_LOGS_BUCKET_NAME__", s3BucketName+"-tf-state-logs", -1) - if err := ioutil.WriteFile(configDestPath, []byte(contents), 0444); err != nil { + if err := os.WriteFile(configDestPath, []byte(contents), 0444); err != nil { t.Fatalf("Error writing temp Terragrunt config to %s: %v", configDestPath, err) } } @@ -4176,7 +4175,7 @@ email := os.Getenv("GOOGLE_IDENTITY_EMAIL") contents = strings.Replace(contents, "__FILL_IN_GCP_EMAIL__", email, -1) - if err := ioutil.WriteFile(configDestPath, []byte(contents), 0444); err != nil { + if err := os.WriteFile(configDestPath, []byte(contents), 0444); err != nil { t.Fatalf("Error writing temp Terragrunt config to %s: %v", configDestPath, err) } } @@ -4758,7 +4757,8 @@ rootPath = util.JoinPath(rootPath, TEST_FIXTURE_DESTROY_WARNING) vpcPath := util.JoinPath(rootPath, "vpc") - appPath := util.JoinPath(rootPath, "app") + appV1Path := util.JoinPath(rootPath, "app-v1") + appV2Path := util.JoinPath(rootPath, "app-v2") cleanupTerraformFolder(t, rootPath) cleanupTerraformFolder(t, vpcPath) @@ -4779,7 +4779,8 @@ assert.NoError(t, err) output := string(stderr.Bytes()) - assert.Equal(t, 1, strings.Count(output, appPath)) + assert.Equal(t, 1, strings.Count(output, appV1Path)) + assert.Equal(t, 1, strings.Count(output, appV2Path)) } func TestTerragruntOutputFromRemoteState(t *testing.T) { @@ -4906,7 +4907,7 @@ require.NoError(t, err) } updatedHcl := strings.Replace(contents, "__TAG_VALUE__", "v0.35.1", -1) - require.NoError(t, ioutil.WriteFile(terragruntHcl, []byte(updatedHcl), 0444)) + require.NoError(t, os.WriteFile(terragruntHcl, []byte(updatedHcl), 0444)) stdout := bytes.Buffer{} stderr := bytes.Buffer{} @@ -4917,7 +4918,7 @@ assert.Equal(t, 1, strings.Count(stdout.String(), "Terraform has been successfully initialized!")) updatedHcl = strings.Replace(contents, "__TAG_VALUE__", "v0.35.2", -1) - require.NoError(t, ioutil.WriteFile(terragruntHcl, []byte(updatedHcl), 0444)) + require.NoError(t, os.WriteFile(terragruntHcl, []byte(updatedHcl), 0444)) stdout = bytes.Buffer{} stderr = bytes.Buffer{} @@ -4963,7 +4964,7 @@ runTerragrunt(t, fmt.Sprintf("terragrunt render-json --with-metadata --terragrunt-non-interactive --terragrunt-log-level debug --terragrunt-working-dir %s --terragrunt-json-out %s", tmpDir, jsonOut)) - jsonBytes, err := ioutil.ReadFile(jsonOut) + jsonBytes, err := os.ReadFile(jsonOut) require.NoError(t, err) var renderedJson = map[string]interface{}{} @@ -5101,7 +5102,7 @@ runTerragrunt(t, fmt.Sprintf("terragrunt render-json --with-metadata --terragrunt-non-interactive --terragrunt-log-level debug --terragrunt-working-dir %s --terragrunt-json-out %s", tmpDir, jsonOut)) - jsonBytes, err := ioutil.ReadFile(jsonOut) + jsonBytes, err := os.ReadFile(jsonOut) require.NoError(t, err) var renderedJson = map[string]interface{}{} @@ -5145,7 +5146,7 @@ runTerragrunt(t, fmt.Sprintf("terragrunt render-json --with-metadata --terragrunt-non-interactive --terragrunt-log-level debug --terragrunt-working-dir %s --terragrunt-json-out %s", tmpDir, jsonOut)) - jsonBytes, err := ioutil.ReadFile(jsonOut) + jsonBytes, err := os.ReadFile(jsonOut) require.NoError(t, err) var renderedJson = map[string]interface{}{} @@ -5213,7 +5214,7 @@ runTerragrunt(t, fmt.Sprintf("terragrunt render-json --with-metadata --terragrunt-non-interactive --terragrunt-log-level debug --terragrunt-working-dir %s --terragrunt-json-out %s", tmpDir, jsonOut)) - jsonBytes, err := ioutil.ReadFile(jsonOut) + jsonBytes, err := os.ReadFile(jsonOut) require.NoError(t, err) var renderedJson = map[string]interface{}{} @@ -5308,7 +5309,7 @@ runTerragrunt(t, fmt.Sprintf("terragrunt render-json --with-metadata --terragrunt-non-interactive --terragrunt-log-level debug --terragrunt-working-dir %s --terragrunt-json-out %s", tmpDir, jsonOut)) - jsonBytes, err := ioutil.ReadFile(jsonOut) + jsonBytes, err := os.ReadFile(jsonOut) require.NoError(t, err) var renderedJson = map[string]interface{}{} @@ -5381,7 +5382,7 @@ runTerragrunt(t, fmt.Sprintf("terragrunt render-json --with-metadata --terragrunt-non-interactive --terragrunt-log-level debug --terragrunt-working-dir %s --terragrunt-json-out %s", tmpDir, jsonOut)) - jsonBytes, err := ioutil.ReadFile(jsonOut) + jsonBytes, err := os.ReadFile(jsonOut) require.NoError(t, err) var renderedJson = map[string]interface{}{} @@ -5720,7 +5721,7 @@ output := stdout.String() - expectedDiff, err := ioutil.ReadFile(util.JoinPath(rootPath, "expected.diff")) + expectedDiff, err := os.ReadFile(util.JoinPath(rootPath, "expected.diff")) assert.NoError(t, err) logBufferContentsLineByLine(t, stdout, "output") @@ -5846,7 +5847,7 @@ // verify that after adding new file, init is executed tfFile := util.JoinPath(tmpEnvPath, TEST_FIXTURE_INIT_CACHE, "app", "project.tf") - if err := ioutil.WriteFile(tfFile, []byte(""), 0644); err != nil { + if err := os.WriteFile(tfFile, []byte(""), 0644); err != nil { t.Fatalf("Error writing new Terraform file to %s: %v", tfFile, err) } @@ -5876,7 +5877,7 @@ jsonOut := filepath.Join(appPath, "terragrunt_rendered.json") - jsonBytes, err := ioutil.ReadFile(jsonOut) + jsonBytes, err := os.ReadFile(jsonOut) require.NoError(t, err) var renderedJson = map[string]interface{}{} @@ -6137,6 +6138,51 @@ runTerragrunt(t, fmt.Sprintf("terragrunt apply -auto-approve --terragrunt-non-interactive --terragrunt-working-dir %s", testPath)) } +func TestRenderJsonDependentModulesTerraform(t *testing.T) { + t.Parallel() + + tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_DESTROY_WARNING) + cleanupTerraformFolder(t, tmpEnvPath) + tmpDir := util.JoinPath(tmpEnvPath, TEST_FIXTURE_DESTROY_WARNING, "vpc") + + jsonOut := filepath.Join(tmpDir, "terragrunt_rendered.json") + runTerragrunt(t, fmt.Sprintf("terragrunt render-json --terragrunt-non-interactive --terragrunt-log-level debug --terragrunt-working-dir %s --terragrunt-json-out %s", tmpDir, jsonOut)) + + jsonBytes, err := ioutil.ReadFile(jsonOut) + require.NoError(t, err) + + var renderedJson = map[string]interface{}{} + require.NoError(t, json.Unmarshal(jsonBytes, &renderedJson)) + + var dependentModules = renderedJson[config.MetadataDependentModules].([]interface{}) + // check if value list contains app-v1 and app-v2 + assert.Contains(t, dependentModules, util.JoinPath(tmpEnvPath, TEST_FIXTURE_DESTROY_WARNING, "app-v1")) + assert.Contains(t, dependentModules, util.JoinPath(tmpEnvPath, TEST_FIXTURE_DESTROY_WARNING, "app-v2")) +} + +func TestRenderJsonDependentModulesMetadataTerraform(t *testing.T) { + t.Parallel() + + tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_DESTROY_WARNING) + cleanupTerraformFolder(t, tmpEnvPath) + tmpDir := util.JoinPath(tmpEnvPath, TEST_FIXTURE_DESTROY_WARNING, "vpc") + + jsonOut := filepath.Join(tmpDir, "terragrunt_rendered.json") + runTerragrunt(t, fmt.Sprintf("terragrunt render-json --with-metadata --terragrunt-non-interactive --terragrunt-log-level debug --terragrunt-working-dir %s --terragrunt-json-out %s", tmpDir, jsonOut)) + + jsonBytes, err := ioutil.ReadFile(jsonOut) + require.NoError(t, err) + + var renderedJson = map[string]map[string]interface{}{} + + require.NoError(t, json.Unmarshal(jsonBytes, &renderedJson)) + + dependentModules := renderedJson[config.MetadataDependentModules]["value"].([]interface{}) + // check if value list contains app-v1 and app-v2 + assert.Contains(t, dependentModules, util.JoinPath(tmpEnvPath, TEST_FIXTURE_DESTROY_WARNING, "app-v1")) + assert.Contains(t, dependentModules, util.JoinPath(tmpEnvPath, TEST_FIXTURE_DESTROY_WARNING, "app-v2")) +} + func validateOutput(t *testing.T, outputs map[string]TerraformOutput, key string, value interface{}) { t.Helper() output, hasPlatform := outputs[key] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/test/integration_tflint_test.go new/terragrunt-0.51.9/test/integration_tflint_test.go --- old/terragrunt-0.51.7/test/integration_tflint_test.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/test/integration_tflint_test.go 2023-10-04 20:33:53.000000000 +0200 @@ -7,7 +7,6 @@ "bytes" "fmt" "io" - "io/ioutil" "os" "regexp" "testing" @@ -93,7 +92,7 @@ out := new(bytes.Buffer) errOut := new(bytes.Buffer) - downloadDir, err := ioutil.TempDir("", "download-dir") + downloadDir, err := os.MkdirTemp("", "download-dir") if err != nil { t.Fatalf("Failed to create temp dir due to error: %v", err) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/tflint/README.md new/terragrunt-0.51.9/tflint/README.md --- old/terragrunt-0.51.7/tflint/README.md 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/tflint/README.md 2023-10-04 20:33:53.000000000 +0200 @@ -1,4 +1,3 @@ -# tflint +# tflint -This package allows us to embed [tflint](https://github.com/terraform-linters/tflint) in Terragrunt, enabling it to be natively executed from the before and after hooks without having to install `tflint` separately. Since `tflint` is licensed with MPL, we are required to let you know where you can find its source code: https://github.com/terraform-linters/tflint. -} +This package allows us to embed [tflint](https://github.com/terraform-linters/tflint) in Terragrunt, enabling it to be natively executed from the before and after hooks without having to install `tflint` separately. Since `tflint` is licensed with MPL, we are required to let you know where you can find its source code: <https://github.com/terraform-linters/tflint>. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/util/file.go new/terragrunt-0.51.9/util/file.go --- old/terragrunt-0.51.7/util/file.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/util/file.go 2023-10-04 20:33:53.000000000 +0200 @@ -3,7 +3,6 @@ import ( "encoding/gob" "io" - "io/ioutil" "os" "path/filepath" "regexp" @@ -34,7 +33,7 @@ } if IsFile(expandedMaybePath) { - contents, err := ioutil.ReadFile(expandedMaybePath) + contents, err := os.ReadFile(expandedMaybePath) if err != nil { return "", errors.WithStackTrace(err) } @@ -152,7 +151,7 @@ if IsDir(match) { continue } - bytes, err := ioutil.ReadFile(match) + bytes, err := os.ReadFile(match) if err != nil { return false, errors.WithStackTrace(err) } @@ -206,7 +205,7 @@ // Return the contents of the file at the given path as a string func ReadFileAsString(path string) (string, error) { - bytes, err := ioutil.ReadFile(path) + bytes, err := os.ReadFile(path) if err != nil { return "", errors.WithStackTraceAndPrefix(err, "Error reading file at path %s", path) } @@ -292,7 +291,7 @@ } defer manifest.Close() - // Why use filepath.Glob here? The original implementation used ioutil.ReadDir, but that method calls lstat on all + // Why use filepath.Glob here? The original implementation used os.ReadDir, but that method calls lstat on all // the files/folders in the directory, including files/folders you may want to explicitly skip. The next attempt // was to use filepath.Walk, but that doesn't work because it ignores symlinks. So, now we turn to filepath.Glob. files, err := filepath.Glob(fmt.Sprintf("%s/*", source)) @@ -368,7 +367,7 @@ // Copy a file from source to destination func CopyFile(source string, destination string) error { - contents, err := ioutil.ReadFile(source) + contents, err := os.ReadFile(source) if err != nil { return errors.WithStackTrace(err) } @@ -383,7 +382,7 @@ return errors.WithStackTrace(err) } - return ioutil.WriteFile(destination, contents, fileInfo.Mode()) + return os.WriteFile(destination, contents, fileInfo.Mode()) } // Windows systems use \ as the path separator *nix uses / diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.7/util/file_test.go new/terragrunt-0.51.9/util/file_test.go --- old/terragrunt-0.51.7/util/file_test.go 2023-09-29 15:33:57.000000000 +0200 +++ new/terragrunt-0.51.9/util/file_test.go 2023-10-04 20:33:53.000000000 +0200 @@ -2,7 +2,6 @@ import ( "errors" - "io/ioutil" "os" "path" "path/filepath" @@ -176,11 +175,11 @@ var testfiles []string // create temp dir - dir, err := ioutil.TempDir("", ".terragrunt-test-dir") + dir, err := os.MkdirTemp("", ".terragrunt-test-dir") require.NoError(t, err) for _, file := range []string{"file1", "file2"} { // create temp files in the dir - f, err := ioutil.TempFile(dir, file) + f, err := os.CreateTemp(dir, file) assert.NoError(t, err, f.Close()) testfiles = append(testfiles, f.Name()) } ++++++ terragrunt.obsinfo ++++++ --- /var/tmp/diff_new_pack.uTuA8A/_old 2023-10-05 20:04:38.241930283 +0200 +++ /var/tmp/diff_new_pack.uTuA8A/_new 2023-10-05 20:04:38.245930428 +0200 @@ -1,5 +1,5 @@ name: terragrunt -version: 0.51.7 -mtime: 1695994437 -commit: 7765fafc434af4089a388148ddfe27e62d35c40d +version: 0.51.9 +mtime: 1696444433 +commit: 1a80dba8786bdca1e157530c153066e5cfdd4a52 ++++++ vendor.tar.gz ++++++ /work/SRC/openSUSE:Factory/terragrunt/vendor.tar.gz /work/SRC/openSUSE:Factory/.terragrunt.new.28202/vendor.tar.gz differ: char 5, line 1