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-09-13 20:45:24 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/terragrunt (Old) and /work/SRC/openSUSE:Factory/.terragrunt.new.1766 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "terragrunt" Wed Sep 13 20:45:24 2023 rev:62 rq:1110793 version:0.50.15 Changes: -------- --- /work/SRC/openSUSE:Factory/terragrunt/terragrunt.changes 2023-09-07 21:14:37.957362556 +0200 +++ /work/SRC/openSUSE:Factory/.terragrunt.new.1766/terragrunt.changes 2023-09-13 20:47:33.252472662 +0200 @@ -1,0 +2,8 @@ +Wed Sep 13 04:57:13 UTC 2023 - ka...@b1-systems.de + +- Update to version 0.50.15: + * Fixed searching for configs with non-default names #2704. + (#2704) + * Updating link to before-and-after-hooks (#2708) + +------------------------------------------------------------------- Old: ---- terragrunt-0.50.14.obscpio New: ---- terragrunt-0.50.15.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ terragrunt.spec ++++++ --- /var/tmp/diff_new_pack.rzR58e/_old 2023-09-13 20:47:34.672523321 +0200 +++ /var/tmp/diff_new_pack.rzR58e/_new 2023-09-13 20:47:34.672523321 +0200 @@ -19,7 +19,7 @@ %define __arch_install_post export NO_BRP_STRIP_DEBUG=true Name: terragrunt -Version: 0.50.14 +Version: 0.50.15 Release: 0 Summary: Thin wrapper for Terraform for working with multiple Terraform modules License: MIT ++++++ _service ++++++ --- /var/tmp/diff_new_pack.rzR58e/_old 2023-09-13 20:47:34.700524320 +0200 +++ /var/tmp/diff_new_pack.rzR58e/_new 2023-09-13 20:47:34.704524463 +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.50.14</param> + <param name="revision">v0.50.15</param> <param name="versionformat">@PARENT_TAG@</param> <param name="changesgenerate">enable</param> <param name="versionrewrite-pattern">v(.*)</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.rzR58e/_old 2023-09-13 20:47:34.720525033 +0200 +++ /var/tmp/diff_new_pack.rzR58e/_new 2023-09-13 20:47:34.724525176 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/gruntwork-io/terragrunt</param> - <param name="changesrevision">d3285f0e44a7b82a1a20598088f529004459c2c7</param></service></servicedata> + <param name="changesrevision">aa17e62bb9012a31ec5f5ed03070be6e8f10d844</param></service></servicedata> (No newline at EOF) ++++++ terragrunt-0.50.14.obscpio -> terragrunt-0.50.15.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.14/cli/app.go new/terragrunt-0.50.15/cli/app.go --- old/terragrunt-0.50.14/cli/app.go 2023-09-06 20:56:07.000000000 +0200 +++ new/terragrunt-0.50.15/cli/app.go 2023-09-11 11:42:31.000000000 +0200 @@ -155,7 +155,10 @@ // --- Terragrunt ConfigPath if opts.TerragruntConfigPath == "" { opts.TerragruntConfigPath = config.GetDefaultConfigPath(opts.WorkingDir) + } else if !filepath.IsAbs(opts.TerragruntConfigPath) && ctx.Command.Name == terraform.CommandName { + opts.TerragruntConfigPath = util.JoinPath(opts.WorkingDir, opts.TerragruntConfigPath) } + opts.TerraformPath = filepath.ToSlash(opts.TerraformPath) opts.ExcludeDirs, err = util.GlobCanonicalPath(opts.WorkingDir, opts.ExcludeDirs...) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.14/config/config.go new/terragrunt-0.50.15/config/config.go --- old/terragrunt-0.50.14/config/config.go 2023-09-06 20:56:07.000000000 +0200 +++ new/terragrunt-0.50.15/config/config.go 2023-09-11 11:42:31.000000000 +0200 @@ -21,14 +21,17 @@ "github.com/zclconf/go-cty/cty" "github.com/gruntwork-io/go-commons/errors" + "github.com/gruntwork-io/go-commons/files" "github.com/gruntwork-io/terragrunt/codegen" "github.com/gruntwork-io/terragrunt/options" "github.com/gruntwork-io/terragrunt/remote" "github.com/gruntwork-io/terragrunt/util" ) -const DefaultTerragruntConfigPath = "terragrunt.hcl" -const DefaultTerragruntJsonConfigPath = "terragrunt.hcl.json" +const ( + DefaultTerragruntConfigPath = "terragrunt.hcl" + DefaultTerragruntJsonConfigPath = "terragrunt.hcl.json" +) const foundInFile = "found_in_file" @@ -54,6 +57,12 @@ MetadataRetrySleepIntervalSec = "retry_sleep_interval_sec" ) +// Order matters, for example if none of the files are found `GetDefaultConfigPath` func returns the last element. +var DefaultTerragruntConfigPaths = []string{ + DefaultTerragruntJsonConfigPath, + DefaultTerragruntConfigPath, +} + // TerragruntConfig represents a parsed and expanded configuration // NOTE: if any attributes are added, make sure to update terragruntConfigAsCty in config_as_cty.go type TerragruntConfig struct { @@ -537,23 +546,25 @@ } -// Return the default hcl path to use for the Terragrunt configuration file in the given directory -func DefaultConfigPath(workingDir string) string { - return util.JoinPath(workingDir, DefaultTerragruntConfigPath) -} - -// Return the default path to use for the Terragrunt Json configuration file in the given directory -func DefaultJsonConfigPath(workingDir string) string { - return util.JoinPath(workingDir, DefaultTerragruntJsonConfigPath) -} - // Return the default path to use for the Terragrunt configuration that exists within the path giving preference to `terragrunt.hcl` func GetDefaultConfigPath(workingDir string) string { - if util.FileNotExists(DefaultConfigPath(workingDir)) && util.FileExists(DefaultJsonConfigPath(workingDir)) { - return DefaultJsonConfigPath(workingDir) + // check if a configuration file was passed as `workingDir`. + if !files.IsDir(workingDir) && files.FileExists(workingDir) { + return workingDir + } + + var configPath string + + for _, configPath = range DefaultTerragruntConfigPaths { + if !filepath.IsAbs(configPath) { + configPath = util.JoinPath(workingDir, configPath) + } + if files.FileExists(configPath) { + break + } } - return DefaultConfigPath(workingDir) + return configPath } // Returns a list of all Terragrunt config files in the given path or any subfolder of the path. A file is a Terragrunt @@ -566,18 +577,25 @@ return err } - // Skip the Terragrunt cache dir entirely - if info.IsDir() && info.Name() == util.TerragruntCacheDir { - return filepath.SkipDir + if !info.IsDir() { + return nil } - isTerragruntModule, err := containsTerragruntModule(path, info, terragruntOptions) - if err != nil { + if ok, err := isTerragruntModuleDir(path, terragruntOptions); err != nil { return err + } else if !ok { + return filepath.SkipDir } - if isTerragruntModule { - configFiles = append(configFiles, GetDefaultConfigPath(path)) + for _, configFile := range append(DefaultTerragruntConfigPaths, filepath.Base(terragruntOptions.TerragruntConfigPath)) { + if !filepath.IsAbs(configFile) { + configFile = util.JoinPath(path, configFile) + } + + if !util.IsDir(configFile) && util.FileExists(configFile) { + configFiles = append(configFiles, configFile) + break + } } return nil @@ -586,14 +604,9 @@ return configFiles, err } -// Returns true if the given path with the given FileInfo contains a Terragrunt module and false otherwise. A path -// contains a Terragrunt module if it contains a Terragrunt configuration file (terragrunt.hcl, terragrunt.hcl.json) -// and is not a cache, data, or download dir. -func containsTerragruntModule(path string, info os.FileInfo, terragruntOptions *options.TerragruntOptions) (bool, error) { - if !info.IsDir() { - return false, nil - } - +// isTerragruntModuleDir returns true if the given path contains a Terragrunt module and false otherwise. The path +// can not contain a cache, data, or download dir. +func isTerragruntModuleDir(path string, terragruntOptions *options.TerragruntOptions) (bool, error) { // Skip the Terragrunt cache dir if util.ContainsPath(path, util.TerragruntCacheDir) { return false, nil @@ -623,10 +636,10 @@ // Skip any custom download dir specified by the user if strings.Contains(canonicalPath, canonicalDownloadPath) { - return false, err + return false, nil } - return util.FileExists(GetDefaultConfigPath(path)), nil + return true, nil } // Read the Terragrunt config file from its default location diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.14/config/config_partial.go new/terragrunt-0.50.15/config/config_partial.go --- old/terragrunt-0.50.14/config/config_partial.go 2023-09-06 20:56:07.000000000 +0200 +++ new/terragrunt-0.50.15/config/config_partial.go 2023-09-11 11:42:31.000000000 +0200 @@ -290,7 +290,7 @@ // Convert dependency blocks into module depenency lists. If we already decoded some dependencies, // merge them in. Otherwise, set as the new list. - dependencies := dependencyBlocksToModuleDependencies(decoded.Dependencies) + dependencies := dependencyBlocksToModuleDependencies(terragruntOptions.WorkingDir, decoded.Dependencies) if output.Dependencies != nil { output.Dependencies.Merge(dependencies) } else { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.14/config/config_test.go new/terragrunt-0.50.15/config/config_test.go --- old/terragrunt-0.50.14/config/config_test.go 2023-09-06 20:56:07.000000000 +0200 +++ new/terragrunt-0.50.15/config/config_test.go 2023-09-11 11:42:31.000000000 +0200 @@ -936,7 +936,7 @@ actual, err := FindConfigFilesInPath("../test/fixture-config-files/multiple-configs", terragruntOptions) assert.Nil(t, err, "Unexpected error: %v", err) - assert.Equal(t, expected, actual) + assert.ElementsMatch(t, expected, actual) } func TestFindConfigFilesInPathMultipleJsonConfigs(t *testing.T) { @@ -953,7 +953,7 @@ actual, err := FindConfigFilesInPath("../test/fixture-config-files/multiple-json-configs", terragruntOptions) assert.Nil(t, err, "Unexpected error: %v", err) - assert.Equal(t, expected, actual) + assert.ElementsMatch(t, expected, actual) } func TestFindConfigFilesInPathMultipleMixedConfigs(t *testing.T) { @@ -970,7 +970,7 @@ actual, err := FindConfigFilesInPath("../test/fixture-config-files/multiple-mixed-configs", terragruntOptions) assert.Nil(t, err, "Unexpected error: %v", err) - assert.Equal(t, expected, actual) + assert.ElementsMatch(t, expected, actual) } func TestFindConfigFilesIgnoresTerragruntCache(t *testing.T) { @@ -1003,7 +1003,7 @@ actual, err := FindConfigFilesInPath("../test/fixture-config-files/ignore-terraform-data-dir", terragruntOptions) assert.Nil(t, err, "Unexpected error: %v", err) - assert.Equal(t, expected, actual) + assert.ElementsMatch(t, expected, actual) } func TestFindConfigFilesIgnoresTerraformDataDirEnv(t *testing.T) { @@ -1021,7 +1021,7 @@ actual, err := FindConfigFilesInPath("../test/fixture-config-files/ignore-terraform-data-dir", terragruntOptions) assert.Nil(t, err, "Unexpected error: %v", err) - assert.Equal(t, expected, actual) + assert.ElementsMatch(t, expected, actual) } func TestFindConfigFilesIgnoresTerraformDataDirEnvPath(t *testing.T) { @@ -1040,7 +1040,7 @@ actual, err := FindConfigFilesInPath("../test/fixture-config-files/ignore-terraform-data-dir", terragruntOptions) assert.Nil(t, err, "Unexpected error: %v", err) - assert.Equal(t, expected, actual) + assert.ElementsMatch(t, expected, actual) } func TestFindConfigFilesIgnoresTerraformDataDirEnvRoot(t *testing.T) { @@ -1063,7 +1063,7 @@ actual, err := FindConfigFilesInPath(workingDir, terragruntOptions) assert.Nil(t, err, "Unexpected error: %v", err) - assert.Equal(t, expected, actual) + assert.ElementsMatch(t, expected, actual) } func TestFindConfigFilesIgnoresDownloadDir(t *testing.T) { @@ -1080,7 +1080,7 @@ actual, err := FindConfigFilesInPath("../test/fixture-config-files/multiple-configs", terragruntOptions) assert.Nil(t, err, "Unexpected error: %v", err) - assert.Equal(t, expected, actual) + assert.ElementsMatch(t, expected, actual) } func mockOptionsForTestWithConfigPath(t *testing.T, configPath string) *options.TerragruntOptions { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.14/config/dependency.go new/terragrunt-0.50.15/config/dependency.go --- old/terragrunt-0.50.14/config/dependency.go 2023-09-06 20:56:07.000000000 +0200 +++ new/terragrunt-0.50.15/config/dependency.go 2023-09-11 11:42:31.000000000 +0200 @@ -177,20 +177,16 @@ // Convert the list of parsed Dependency blocks into a list of module dependencies. Each output block should // become a dependency of the current config, since that module has to be applied before we can read the output. -func dependencyBlocksToModuleDependencies(decodedDependencyBlocks []Dependency) *ModuleDependencies { +func dependencyBlocksToModuleDependencies(workingDir string, decodedDependencyBlocks []Dependency) *ModuleDependencies { if len(decodedDependencyBlocks) == 0 { return nil } paths := []string{} for _, decodedDependencyBlock := range decodedDependencyBlocks { - configPath := decodedDependencyBlock.ConfigPath - if util.IsFile(configPath) && filepath.Base(configPath) == DefaultTerragruntConfigPath { - // dependencies system expects the directory containing the terragrunt.hcl file - configPath = filepath.Dir(configPath) - } - paths = append(paths, configPath) + paths = append(paths, decodedDependencyBlock.ConfigPath) } + return &ModuleDependencies{Paths: paths} } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.14/configstack/errors.go new/terragrunt-0.50.15/configstack/errors.go --- old/terragrunt-0.50.14/configstack/errors.go 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.50.15/configstack/errors.go 2023-09-11 11:42:31.000000000 +0200 @@ -0,0 +1,34 @@ +package configstack + +import "fmt" + +// Custom error types + +type UnrecognizedDependency struct { + ModulePath string + DependencyPath string + TerragruntConfigPaths []string +} + +func (err UnrecognizedDependency) Error() string { + return fmt.Sprintf("Module %s specifies %s as a dependency, but that dependency was not one of the ones found while scanning subfolders: %v", err.ModulePath, err.DependencyPath, err.TerragruntConfigPaths) +} + +type ErrorProcessingModule struct { + UnderlyingError error + ModulePath string + HowThisModuleWasFound string +} + +func (err ErrorProcessingModule) Error() string { + return fmt.Sprintf("Error processing module at '%s'. How this module was found: %s. Underlying error: %v", err.ModulePath, err.HowThisModuleWasFound, err.UnderlyingError) +} + +type InfiniteRecursion struct { + RecursionLevel int + Modules map[string]*TerraformModule +} + +func (err InfiniteRecursion) Error() string { + return fmt.Sprintf("Hit what seems to be an infinite recursion after going %d levels deep. Please check for a circular dependency! Modules involved: %v", err.RecursionLevel, err.Modules) +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.14/configstack/module.go new/terragrunt-0.50.15/configstack/module.go --- old/terragrunt-0.50.14/configstack/module.go 2023-09-06 20:56:07.000000000 +0200 +++ new/terragrunt-0.50.15/configstack/module.go 2023-09-11 11:42:31.000000000 +0200 @@ -11,6 +11,7 @@ "github.com/gruntwork-io/go-commons/collections" "github.com/gruntwork-io/go-commons/errors" + "github.com/gruntwork-io/go-commons/files" "github.com/gruntwork-io/terragrunt/config" "github.com/gruntwork-io/terragrunt/options" "github.com/gruntwork-io/terragrunt/shell" @@ -223,12 +224,19 @@ moduleMap := map[string]*TerraformModule{} for _, terragruntConfigPath := range canonicalTerragruntConfigPaths { - module, err := resolveTerraformModule(terragruntConfigPath, terragruntOptions, childTerragruntConfig, howTheseModulesWereFound) + module, err := resolveTerraformModule(terragruntConfigPath, moduleMap, terragruntOptions, childTerragruntConfig, howTheseModulesWereFound) if err != nil { return moduleMap, err } + if module != nil { moduleMap[module.Path] = module + + dependencies, err := resolveDependenciesForModule(module, moduleMap, terragruntOptions, childTerragruntConfig, true) + if err != nil { + return moduleMap, err + } + moduleMap = collections.MergeMaps(moduleMap, dependencies) } } @@ -238,12 +246,16 @@ // Create a TerraformModule struct for the Terraform module specified by the given Terragrunt configuration file path. // Note that this method will NOT fill in the Dependencies field of the TerraformModule struct (see the // crosslinkDependencies method for that). -func resolveTerraformModule(terragruntConfigPath string, terragruntOptions *options.TerragruntOptions, childTerragruntConfig *config.TerragruntConfig, howThisModuleWasFound string) (*TerraformModule, error) { +func resolveTerraformModule(terragruntConfigPath string, moduleMap map[string]*TerraformModule, terragruntOptions *options.TerragruntOptions, childTerragruntConfig *config.TerragruntConfig, howThisModuleWasFound string) (*TerraformModule, error) { modulePath, err := util.CanonicalPath(filepath.Dir(terragruntConfigPath), ".") if err != nil { return nil, err } + if _, ok := moduleMap[modulePath]; ok { + return nil, nil + } + // Clone the options struct so we don't modify the original one. This is especially important as run-all operations // happen concurrently. opts := terragruntOptions.Clone(terragruntConfigPath) @@ -343,7 +355,7 @@ sortedKeys := getSortedKeys(moduleMap) for _, key := range sortedKeys { module := moduleMap[key] - externalDependencies, err := resolveExternalDependenciesForModule(module, modulesToSkip, terragruntOptions, childTerragruntConfig) + externalDependencies, err := resolveDependenciesForModule(module, modulesToSkip, terragruntOptions, childTerragruntConfig, false) if err != nil { return externalDependencies, err } @@ -377,12 +389,10 @@ return allExternalDependencies, nil } -// Look through the dependencies of the given module and resolve the "external" dependency paths listed in the module's -// config (i.e. those dependencies not in the given list of Terragrunt config canonical file paths). These external -// dependencies are outside of the current working directory, which means they may not be part of the environment the -// user is trying to apply-all or destroy-all. Note that this method will NOT fill in the Dependencies field of the -// TerraformModule struct (see the crosslinkDependencies method for that). -func resolveExternalDependenciesForModule(module *TerraformModule, moduleMap map[string]*TerraformModule, terragruntOptions *options.TerragruntOptions, chilTerragruntConfig *config.TerragruntConfig) (map[string]*TerraformModule, error) { +// resolveDependenciesForModule looks through the dependencies of the given module and resolve the dependency paths listed in the module's config. +// If `skipExternal` is true, the func returns only dependencies that are inside of the current working directory, which means they are part of the environment the +// user is trying to apply-all or destroy-all. Note that this method will NOT fill in the Dependencies field of the TerraformModule struct (see the crosslinkDependencies method for that). +func resolveDependenciesForModule(module *TerraformModule, moduleMap map[string]*TerraformModule, terragruntOptions *options.TerragruntOptions, chilTerragruntConfig *config.TerragruntConfig, skipExternal bool) (map[string]*TerraformModule, error) { if module.Config.Dependencies == nil || len(module.Config.Dependencies.Paths) == 0 { return map[string]*TerraformModule{}, nil } @@ -394,7 +404,12 @@ return map[string]*TerraformModule{}, err } + if skipExternal && !util.HasPathPrefix(dependencyPath, terragruntOptions.WorkingDir) { + continue + } + terragruntConfigPath := config.GetDefaultConfigPath(dependencyPath) + if _, alreadyContainsModule := moduleMap[dependencyPath]; !alreadyContainsModule { externalTerragruntConfigPaths = append(externalTerragruntConfigPaths, terragruntConfigPath) } @@ -480,6 +495,10 @@ return dependencies, nil } + if files.FileExists(dependencyModulePath) && !files.IsDir(dependencyModulePath) { + dependencyModulePath = filepath.Dir(dependencyModulePath) + } + dependencyModule, foundModule := moduleMap[dependencyModulePath] if !foundModule { err := UnrecognizedDependency{ @@ -573,37 +592,6 @@ return matchedModules } -// Custom error types - -type UnrecognizedDependency struct { - ModulePath string - DependencyPath string - TerragruntConfigPaths []string -} - -func (err UnrecognizedDependency) Error() string { - return fmt.Sprintf("Module %s specifies %s as a dependency, but that dependency was not one of the ones found while scanning subfolders: %v", err.ModulePath, err.DependencyPath, err.TerragruntConfigPaths) -} - -type ErrorProcessingModule struct { - UnderlyingError error - ModulePath string - HowThisModuleWasFound string -} - -func (err ErrorProcessingModule) Error() string { - return fmt.Sprintf("Error processing module at '%s'. How this module was found: %s. Underlying error: %v", err.ModulePath, err.HowThisModuleWasFound, err.UnderlyingError) -} - -type InfiniteRecursion struct { - RecursionLevel int - Modules map[string]*TerraformModule -} - -func (err InfiniteRecursion) Error() string { - return fmt.Sprintf("Hit what seems to be an infinite recursion after going %d levels deep. Please check for a circular dependency! Modules involved: %v", err.RecursionLevel, err.Modules) -} - // ForceLogLevelHook - log hook which can change log level for messages which contains specific substrings type ForceLogLevelHook struct { TriggerLevels []logrus.Level diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.14/docs/_pages/index/_key-features.html new/terragrunt-0.50.15/docs/_pages/index/_key-features.html --- old/terragrunt-0.50.14/docs/_pages/index/_key-features.html 2023-09-06 20:56:07.000000000 +0200 +++ new/terragrunt-0.50.15/docs/_pages/index/_key-features.html 2023-09-11 11:42:31.000000000 +0200 @@ -80,7 +80,7 @@ <div class="col-xs-12 col-md-5 order-md-2"> <h3><strong>Before & After</strong> hooks</h3> <p class="subtitle">Execute custom code before or after running Terraform.</p> - <a class="btn btn-primary hidden-xs hidden-sm" href="{{site.baseurl}}/docs/features/before-and-after-hooks/#before-and-after-hooks">Learn more</a> + <a class="btn btn-primary hidden-xs hidden-sm" href="{{site.baseurl}}/docs/features/hooks/#before-and-after-hooks">Learn more</a> </div> <div class="col-xs-12 col-md-7 order-md-1"> <div class="code-snippet"> @@ -97,7 +97,7 @@ } }</code></pre> </div> - <a class="btn btn-primary hidden-md hidden-lg" href="{{site.baseurl}}/docs/features/before-and-after-hooks/#before-and-after-hooks">Learn more</a> + <a class="btn btn-primary hidden-md hidden-lg" href="{{site.baseurl}}/docs/features/hooks/#before-and-after-hooks">Learn more</a> </div> </div> </div> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.14/pkg/cli/command.go new/terragrunt-0.50.15/pkg/cli/command.go --- old/terragrunt-0.50.14/pkg/cli/command.go 2023-09-06 20:56:07.000000000 +0200 +++ new/terragrunt-0.50.15/pkg/cli/command.go 2023-09-11 11:42:31.000000000 +0200 @@ -118,6 +118,11 @@ return err } + if cmd.IsRoot && ctx.App.DefaultCommand != nil { + err = ctx.App.DefaultCommand.Run(ctx, args...) + return err + } + if ctx.App.CommonBefore != nil { if err = ctx.App.CommonBefore(ctx); err != nil { return ctx.App.handleExitCoder(err) @@ -130,11 +135,6 @@ } } - if cmd.IsRoot && ctx.App.DefaultCommand != nil { - err = ctx.App.DefaultCommand.Run(ctx, args...) - return err - } - return nil } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.14/test/fixture-config-files/with-non-default-names/app/main.hcl new/terragrunt-0.50.15/test/fixture-config-files/with-non-default-names/app/main.hcl --- old/terragrunt-0.50.14/test/fixture-config-files/with-non-default-names/app/main.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.50.15/test/fixture-config-files/with-non-default-names/app/main.hcl 2023-09-11 11:42:31.000000000 +0200 @@ -0,0 +1,3 @@ +include "parent" { + path = "../parent.hcl" +} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.14/test/fixture-config-files/with-non-default-names/app/main.tf new/terragrunt-0.50.15/test/fixture-config-files/with-non-default-names/app/main.tf --- old/terragrunt-0.50.14/test/fixture-config-files/with-non-default-names/app/main.tf 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.50.15/test/fixture-config-files/with-non-default-names/app/main.tf 2023-09-11 11:42:31.000000000 +0200 @@ -0,0 +1 @@ +# Intentionally empty diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.14/test/fixture-config-files/with-non-default-names/common.hcl new/terragrunt-0.50.15/test/fixture-config-files/with-non-default-names/common.hcl --- old/terragrunt-0.50.14/test/fixture-config-files/with-non-default-names/common.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.50.15/test/fixture-config-files/with-non-default-names/common.hcl 2023-09-11 11:42:31.000000000 +0200 @@ -0,0 +1,3 @@ +locals { + common = run_cmd("echo", "common_hcl") +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.14/test/fixture-config-files/with-non-default-names/dependency/another-name.hcl new/terragrunt-0.50.15/test/fixture-config-files/with-non-default-names/dependency/another-name.hcl --- old/terragrunt-0.50.14/test/fixture-config-files/with-non-default-names/dependency/another-name.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.50.15/test/fixture-config-files/with-non-default-names/dependency/another-name.hcl 2023-09-11 11:42:31.000000000 +0200 @@ -0,0 +1,7 @@ +locals { + parent_var = run_cmd("echo", "dependency_hcl") +} + +include "common" { + path = "../common.hcl" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.14/test/fixture-config-files/with-non-default-names/parent.hcl new/terragrunt-0.50.15/test/fixture-config-files/with-non-default-names/parent.hcl --- old/terragrunt-0.50.14/test/fixture-config-files/with-non-default-names/parent.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.50.15/test/fixture-config-files/with-non-default-names/parent.hcl 2023-09-11 11:42:31.000000000 +0200 @@ -0,0 +1,12 @@ +locals { + parent_var = run_cmd("echo", "parent_hcl_file") +} + +dependency "dependency" { + config_path = "../dependency/another-name.hcl" + + mock_outputs = { + mock_key = "mock_value" + } + +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.14/test/integration_test.go new/terragrunt-0.50.15/test/integration_test.go --- old/terragrunt-0.50.14/test/integration_test.go 2023-09-06 20:56:07.000000000 +0200 +++ new/terragrunt-0.50.15/test/integration_test.go 2023-09-11 11:42:31.000000000 +0200 @@ -69,6 +69,7 @@ TEST_FIXTURE_ENV_VARS_BLOCK_PATH = "fixture-env-vars-block/" TEST_FIXTURE_SKIP = "fixture-skip/" TEST_FIXTURE_CONFIG_SINGLE_JSON_PATH = "fixture-config-files/single-json-config" + TEST_FIXTURE_CONFIG_WITH_NON_DEFAULT_NAMES = "fixture-config-files/with-non-default-names" TEST_FIXTURE_PREVENT_DESTROY_OVERRIDE = "fixture-prevent-destroy-override/child" TEST_FIXTURE_PREVENT_DESTROY_NOT_SET = "fixture-prevent-destroy-not-set/child" TEST_FIXTURE_LOCAL_PREVENT_DESTROY = "fixture-download/local-with-prevent-destroy" @@ -761,6 +762,42 @@ runTerragrunt(t, fmt.Sprintf("terragrunt plan --terragrunt-non-interactive --terragrunt-working-dir %s", rootTerragruntConfigPath)) } +func TestTerragruntWorksWithNonDefaultConfigNamesAndRunAllCommand(t *testing.T) { + t.Parallel() + + tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_CONFIG_WITH_NON_DEFAULT_NAMES) + tmpEnvPath = path.Join(tmpEnvPath, TEST_FIXTURE_CONFIG_WITH_NON_DEFAULT_NAMES) + + stdout := bytes.Buffer{} + stderr := bytes.Buffer{} + + err := runTerragruntCommand(t, fmt.Sprintf("terragrunt run-all apply --terragrunt-config main.hcl --terragrunt-non-interactive --terragrunt-working-dir %s", tmpEnvPath), &stdout, &stderr) + require.NoError(t, err) + + out := stdout.String() + assert.Equal(t, 1, strings.Count(out, "parent_hcl_file")) + assert.Equal(t, 1, strings.Count(out, "dependency_hcl")) + assert.Equal(t, 1, strings.Count(out, "common_hcl")) +} + +func TestTerragruntWorksWithNonDefaultConfigNames(t *testing.T) { + t.Parallel() + + tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_CONFIG_WITH_NON_DEFAULT_NAMES) + tmpEnvPath = path.Join(tmpEnvPath, TEST_FIXTURE_CONFIG_WITH_NON_DEFAULT_NAMES) + + stdout := bytes.Buffer{} + stderr := bytes.Buffer{} + + err := runTerragruntCommand(t, fmt.Sprintf("terragrunt apply --terragrunt-config main.hcl --terragrunt-non-interactive --terragrunt-working-dir %s", filepath.Join(tmpEnvPath, "app")), &stdout, &stderr) + require.NoError(t, err) + + out := stdout.String() + assert.Equal(t, 1, strings.Count(out, "parent_hcl_file")) + assert.Equal(t, 1, strings.Count(out, "dependency_hcl")) + assert.Equal(t, 1, strings.Count(out, "common_hcl")) +} + func TestTerragruntReportsTerraformErrorsWithPlanAll(t *testing.T) { cleanupTerraformFolder(t, TEST_FIXTURE_FAILED_TERRAFORM) ++++++ terragrunt.obsinfo ++++++ --- /var/tmp/diff_new_pack.rzR58e/_old 2023-09-13 20:47:35.448551005 +0200 +++ /var/tmp/diff_new_pack.rzR58e/_new 2023-09-13 20:47:35.452551148 +0200 @@ -1,5 +1,5 @@ name: terragrunt -version: 0.50.14 -mtime: 1694026567 -commit: d3285f0e44a7b82a1a20598088f529004459c2c7 +version: 0.50.15 +mtime: 1694425351 +commit: aa17e62bb9012a31ec5f5ed03070be6e8f10d844 ++++++ vendor.tar.gz ++++++ /work/SRC/openSUSE:Factory/terragrunt/vendor.tar.gz /work/SRC/openSUSE:Factory/.terragrunt.new.1766/vendor.tar.gz differ: char 5, line 1