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-28 00:25:36 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/terragrunt (Old) and /work/SRC/openSUSE:Factory/.terragrunt.new.23327 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "terragrunt" Thu Sep 28 00:25:36 2023 rev:67 rq:1113774 version:0.51.5 Changes: -------- --- /work/SRC/openSUSE:Factory/terragrunt/terragrunt.changes 2023-09-21 22:24:13.291419602 +0200 +++ /work/SRC/openSUSE:Factory/.terragrunt.new.23327/terragrunt.changes 2023-09-28 00:26:10.426142106 +0200 @@ -1,0 +2,6 @@ +Wed Sep 27 04:35:36 UTC 2023 - ka...@b1-systems.de + +- Update to version 0.51.5: + * #2280 Add validation of generate blocks from includes (#2281) + +------------------------------------------------------------------- Old: ---- terragrunt-0.51.4.obscpio New: ---- terragrunt-0.51.5.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ terragrunt.spec ++++++ --- /var/tmp/diff_new_pack.yJ4onv/_old 2023-09-28 00:26:13.330246932 +0200 +++ /var/tmp/diff_new_pack.yJ4onv/_new 2023-09-28 00:26:13.338247221 +0200 @@ -19,7 +19,7 @@ %define __arch_install_post export NO_BRP_STRIP_DEBUG=true Name: terragrunt -Version: 0.51.4 +Version: 0.51.5 Release: 0 Summary: Thin wrapper for Terraform for working with multiple Terraform modules License: MIT ++++++ _service ++++++ --- /var/tmp/diff_new_pack.yJ4onv/_old 2023-09-28 00:26:13.506253286 +0200 +++ /var/tmp/diff_new_pack.yJ4onv/_new 2023-09-28 00:26:13.510253429 +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.4</param> + <param name="revision">v0.51.5</param> <param name="versionformat">@PARENT_TAG@</param> <param name="changesgenerate">enable</param> <param name="versionrewrite-pattern">v(.*)</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.yJ4onv/_old 2023-09-28 00:26:13.566255452 +0200 +++ /var/tmp/diff_new_pack.yJ4onv/_new 2023-09-28 00:26:13.594256462 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/gruntwork-io/terragrunt</param> - <param name="changesrevision">e740048bc7512a9212044a9a0dd9f327e356a2c4</param></service></servicedata> + <param name="changesrevision">f719031b628de002a94c88b02a0e2c7db75b2c6c</param></service></servicedata> (No newline at EOF) ++++++ terragrunt-0.51.4.obscpio -> terragrunt-0.51.5.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.4/config/include.go new/terragrunt-0.51.5/config/include.go --- old/terragrunt-0.51.4/config/include.go 2023-09-21 11:19:00.000000000 +0200 +++ new/terragrunt-0.51.5/config/include.go 2023-09-26 18:25:04.000000000 +0200 @@ -6,6 +6,8 @@ "path/filepath" "strings" + "github.com/gruntwork-io/terragrunt/codegen" + "github.com/hashicorp/hcl/v2" "github.com/hashicorp/hcl/v2/hclwrite" "github.com/imdario/mergo" @@ -126,7 +128,9 @@ terragruntOptions.Logger.Debugf("Included config %s has strategy no merge: not merging config in.", includeConfig.Path) case ShallowMerge: terragruntOptions.Logger.Debugf("Included config %s has strategy shallow merge: merging config in (shallow).", includeConfig.Path) - parsedIncludeConfig.Merge(baseConfig, terragruntOptions) + if err := parsedIncludeConfig.Merge(baseConfig, terragruntOptions); err != nil { + return nil, err + } baseConfig = parsedIncludeConfig case DeepMerge: terragruntOptions.Logger.Debugf("Included config %s has strategy deep merge: merging config in (deep).", includeConfig.Path) @@ -174,7 +178,9 @@ terragruntOptions.Logger.Debugf("[Partial] Included config %s has strategy no merge: not merging config in.", includeConfig.Path) case ShallowMerge: terragruntOptions.Logger.Debugf("[Partial] Included config %s has strategy shallow merge: merging config in (shallow).", includeConfig.Path) - parsedIncludeConfig.Merge(baseConfig, terragruntOptions) + if err := parsedIncludeConfig.Merge(baseConfig, terragruntOptions); err != nil { + return nil, err + } baseConfig = parsedIncludeConfig case DeepMerge: terragruntOptions.Logger.Debugf("[Partial] Included config %s has strategy deep merge: merging config in (deep).", includeConfig.Path) @@ -247,7 +253,7 @@ // NOTE: dependencies block is a special case and is merged deeply. This is necessary to ensure the configstack system // works correctly, as it uses the `Dependencies` list to track the dependencies of modules for graph building purposes. // This list includes the dependencies added from dependency blocks, which is handled in a different stage. -func (targetConfig *TerragruntConfig) Merge(sourceConfig *TerragruntConfig, terragruntOptions *options.TerragruntOptions) { +func (targetConfig *TerragruntConfig) Merge(sourceConfig *TerragruntConfig, terragruntOptions *options.TerragruntOptions) error { // Merge simple attributes first if sourceConfig.DownloadDir != "" { targetConfig.DownloadDir = sourceConfig.DownloadDir @@ -326,6 +332,12 @@ // Merge the generate configs. This is a shallow merge. Meaning, if the child has the same name generate block, then the // child's generate block will override the parent's block. + + err := validateGenerateConfigs(&sourceConfig.GenerateConfigs, &targetConfig.GenerateConfigs) + if err != nil { + return err + } + for key, val := range sourceConfig.GenerateConfigs { targetConfig.GenerateConfigs[key] = val } @@ -335,6 +347,8 @@ } copyFieldsMetadata(sourceConfig, targetConfig) + + return nil } // DeepMerge performs a deep merge of the given sourceConfig into the targetConfig. Deep merge is defined as follows: @@ -861,6 +875,22 @@ } } +// validateGenerateConfigs Validate if exists duplicate generate configs. +func validateGenerateConfigs(sourceConfig *map[string]codegen.GenerateConfig, targetConfig *map[string]codegen.GenerateConfig) error { + var duplicatedNames []string + for key := range *targetConfig { + if _, found := (*sourceConfig)[key]; found { + duplicatedNames = append(duplicatedNames, key) + } + } + + if len(duplicatedNames) != 0 { + return DuplicatedGenerateBlocks{duplicatedNames} + } + + return nil +} + // Custom error types type MultipleBareIncludeBlocksErr struct{} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.4/config/include_test.go new/terragrunt-0.51.5/config/include_test.go --- old/terragrunt-0.51.4/config/include_test.go 2023-09-21 11:19:00.000000000 +0200 +++ new/terragrunt-0.51.5/config/include_test.go 2023-09-26 18:25:04.000000000 +0200 @@ -134,7 +134,8 @@ testCase.expected.TerragruntDependencies = []Dependency{} } - testCase.includedConfig.Merge(testCase.config, mockOptionsForTest(t)) + err := testCase.includedConfig.Merge(testCase.config, mockOptionsForTest(t)) + assert.NoError(t, err) assert.Equal(t, testCase.expected, testCase.includedConfig) } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.4/test/fixture-codegen/generate-block/nested/child_overwrite/terragrunt.hcl new/terragrunt-0.51.5/test/fixture-codegen/generate-block/nested/child_overwrite/terragrunt.hcl --- old/terragrunt-0.51.4/test/fixture-codegen/generate-block/nested/child_overwrite/terragrunt.hcl 2023-09-21 11:19:00.000000000 +0200 +++ new/terragrunt-0.51.5/test/fixture-codegen/generate-block/nested/child_overwrite/terragrunt.hcl 2023-09-26 18:25:04.000000000 +0200 @@ -1,5 +1,6 @@ include { path = "${get_terragrunt_dir()}/../root.hcl" + merge_strategy = "deep" } generate "backend" { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.4/test/fixture-codegen/generate-block/same_name_includes_error/app1.hcl new/terragrunt-0.51.5/test/fixture-codegen/generate-block/same_name_includes_error/app1.hcl --- old/terragrunt-0.51.4/test/fixture-codegen/generate-block/same_name_includes_error/app1.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.51.5/test/fixture-codegen/generate-block/same_name_includes_error/app1.hcl 2023-09-26 18:25:04.000000000 +0200 @@ -0,0 +1,6 @@ +generate "backend" { + path = "backend.txt" + contents = "backend 2" + if_exists = "overwrite_terragrunt" +} + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.4/test/fixture-codegen/generate-block/same_name_includes_error/app2.hcl new/terragrunt-0.51.5/test/fixture-codegen/generate-block/same_name_includes_error/app2.hcl --- old/terragrunt-0.51.4/test/fixture-codegen/generate-block/same_name_includes_error/app2.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.51.5/test/fixture-codegen/generate-block/same_name_includes_error/app2.hcl 2023-09-26 18:25:04.000000000 +0200 @@ -0,0 +1,6 @@ +generate "backend" { + path = "backend.txt" + contents = "other_module" + if_exists = "overwrite_terragrunt" +} + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.4/test/fixture-codegen/generate-block/same_name_includes_error/terragrunt.hcl new/terragrunt-0.51.5/test/fixture-codegen/generate-block/same_name_includes_error/terragrunt.hcl --- old/terragrunt-0.51.4/test/fixture-codegen/generate-block/same_name_includes_error/terragrunt.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.51.5/test/fixture-codegen/generate-block/same_name_includes_error/terragrunt.hcl 2023-09-26 18:25:04.000000000 +0200 @@ -0,0 +1,7 @@ +include "app1" { + path = "app1.hcl" +} + +include "app2" { + path = "app2.hcl" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.51.4/test/integration_test.go new/terragrunt-0.51.5/test/integration_test.go --- old/terragrunt-0.51.4/test/integration_test.go 2023-09-21 11:19:00.000000000 +0200 +++ new/terragrunt-0.51.5/test/integration_test.go 2023-09-26 18:25:04.000000000 +0200 @@ -3640,6 +3640,23 @@ assert.Contains(t, parsedError.BlockName, "backend") } +func TestTerragruntGenerateBlockSameNameIncludeFail(t *testing.T) { + t.Parallel() + + generateTestCase := filepath.Join(TEST_FIXTURE_CODEGEN_PATH, "generate-block", "same_name_includes_error") + cleanupTerraformFolder(t, generateTestCase) + cleanupTerragruntFolder(t, generateTestCase) + + stdout := bytes.Buffer{} + stderr := bytes.Buffer{} + err := runTerragruntCommand(t, fmt.Sprintf("terragrunt init --terragrunt-working-dir %s", generateTestCase), &stdout, &stderr) + require.Error(t, err) + parsedError, ok := errors.Unwrap(err).(config.DuplicatedGenerateBlocks) + assert.True(t, ok) + assert.True(t, len(parsedError.BlockName) == 1) + assert.Contains(t, parsedError.BlockName, "backend") +} + func TestTerragruntGenerateBlockMultipleSameNameFail(t *testing.T) { t.Parallel() ++++++ terragrunt.obsinfo ++++++ --- /var/tmp/diff_new_pack.yJ4onv/_old 2023-09-28 00:26:14.498289094 +0200 +++ /var/tmp/diff_new_pack.yJ4onv/_new 2023-09-28 00:26:14.502289237 +0200 @@ -1,5 +1,5 @@ name: terragrunt -version: 0.51.4 -mtime: 1695287940 -commit: e740048bc7512a9212044a9a0dd9f327e356a2c4 +version: 0.51.5 +mtime: 1695745504 +commit: f719031b628de002a94c88b02a0e2c7db75b2c6c ++++++ vendor.tar.gz ++++++ /work/SRC/openSUSE:Factory/terragrunt/vendor.tar.gz /work/SRC/openSUSE:Factory/.terragrunt.new.23327/vendor.tar.gz differ: char 5, line 1