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-15 22:05:41 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/terragrunt (Old) and /work/SRC/openSUSE:Factory/.terragrunt.new.1766 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "terragrunt" Fri Sep 15 22:05:41 2023 rev:64 rq:1111535 version:0.50.17 Changes: -------- --- /work/SRC/openSUSE:Factory/terragrunt/terragrunt.changes 2023-09-14 16:28:12.112018306 +0200 +++ /work/SRC/openSUSE:Factory/.terragrunt.new.1766/terragrunt.changes 2023-09-15 22:11:10.789373296 +0200 @@ -1,0 +2,6 @@ +Fri Sep 15 09:26:32 UTC 2023 - ka...@b1-systems.de + +- Update to version 0.50.17: + * Add enabled property for dependency (#2712) + +------------------------------------------------------------------- Old: ---- terragrunt-0.50.16.obscpio New: ---- terragrunt-0.50.17.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ terragrunt.spec ++++++ --- /var/tmp/diff_new_pack.JnAWne/_old 2023-09-15 22:11:12.441432365 +0200 +++ /var/tmp/diff_new_pack.JnAWne/_new 2023-09-15 22:11:12.445432508 +0200 @@ -19,7 +19,7 @@ %define __arch_install_post export NO_BRP_STRIP_DEBUG=true Name: terragrunt -Version: 0.50.16 +Version: 0.50.17 Release: 0 Summary: Thin wrapper for Terraform for working with multiple Terraform modules License: MIT ++++++ _service ++++++ --- /var/tmp/diff_new_pack.JnAWne/_old 2023-09-15 22:11:12.477433652 +0200 +++ /var/tmp/diff_new_pack.JnAWne/_new 2023-09-15 22:11:12.477433652 +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.16</param> + <param name="revision">v0.50.17</param> <param name="versionformat">@PARENT_TAG@</param> <param name="changesgenerate">enable</param> <param name="versionrewrite-pattern">v(.*)</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.JnAWne/_old 2023-09-15 22:11:12.501434510 +0200 +++ /var/tmp/diff_new_pack.JnAWne/_new 2023-09-15 22:11:12.501434510 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/gruntwork-io/terragrunt</param> - <param name="changesrevision">c0e6eddb0715912ca5402da581356761b1243fdb</param></service></servicedata> + <param name="changesrevision">b9b239dca970724b121b7be636a8196446beb9de</param></service></servicedata> (No newline at EOF) ++++++ terragrunt-0.50.16.obscpio -> terragrunt-0.50.17.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.16/config/config_partial_test.go new/terragrunt-0.50.17/config/config_partial_test.go --- old/terragrunt-0.50.16/config/config_partial_test.go 2023-09-13 15:55:15.000000000 +0200 +++ new/terragrunt-0.50.17/config/config_partial_test.go 2023-09-14 20:36:41.000000000 +0200 @@ -315,3 +315,21 @@ require.NotNil(t, terragruntConfig.Terraform.Source) assert.Equal(t, *terragruntConfig.Terraform.Source, "../../modules/app") } + +func TestOptionalDependenciesAreSkipped(t *testing.T) { + t.Parallel() + + config := ` +dependency "vpc" { + config_path = "../vpc" +} +dependency "ec2" { + config_path = "../ec2" + enabled = false +} +` + + terragruntConfig, err := PartialParseConfigString(config, mockOptionsForTest(t), nil, DefaultTerragruntConfigPath, []PartialDecodeSectionType{DependencyBlock}) + require.NoError(t, err) + assert.Len(t, terragruntConfig.Dependencies.Paths, 1) +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.16/config/dependency.go new/terragrunt-0.50.17/config/dependency.go --- old/terragrunt-0.50.16/config/dependency.go 2023-09-13 15:55:15.000000000 +0200 +++ new/terragrunt-0.50.17/config/dependency.go 2023-09-14 20:36:41.000000000 +0200 @@ -35,6 +35,7 @@ type Dependency struct { Name string `hcl:",label" cty:"name"` + Enabled *bool `hcl:"enabled,attr" cty:"enabled"` ConfigPath string `hcl:"config_path,attr" cty:"config_path"` SkipOutputs *bool `hcl:"skip_outputs,attr" cty:"skip"` MockOutputs *cty.Value `hcl:"mock_outputs,attr" cty:"mock_outputs"` @@ -61,6 +62,10 @@ targetDepConfig.ConfigPath = sourceDepConfig.ConfigPath } + if sourceDepConfig.Enabled != nil { + targetDepConfig.Enabled = sourceDepConfig.Enabled + } + if sourceDepConfig.SkipOutputs != nil { targetDepConfig.SkipOutputs = sourceDepConfig.SkipOutputs } @@ -107,7 +112,15 @@ // Given a dependency config, we should only attempt to get the outputs if SkipOutputs is nil or false func (dependencyConfig Dependency) shouldGetOutputs() bool { - return dependencyConfig.SkipOutputs == nil || !(*dependencyConfig.SkipOutputs) + return dependencyConfig.isEnabled() && (dependencyConfig.SkipOutputs == nil || !*dependencyConfig.SkipOutputs) +} + +// isEnabled returns true if the dependency is enabled +func (dependencyConfig Dependency) isEnabled() bool { + if dependencyConfig.Enabled == nil { + return true + } + return *dependencyConfig.Enabled } // Given a dependency config, we should only attempt to merge mocks outputs with the outputs if MockOutputsMergeWithState is not nil or true @@ -160,6 +173,16 @@ return nil, err } + // Skip disabled dependencies + updatedDependencies := terragruntDependency{} + for _, dep := range decodedDependency.Dependencies { + if !dep.isEnabled() { + continue + } + updatedDependencies.Dependencies = append(updatedDependencies.Dependencies, dep) + } + decodedDependency = updatedDependencies + // Merge in included dependencies if trackInclude != nil { mergedDecodedDependency, err := handleIncludeForDependency(decodedDependency, trackInclude, terragruntOptions) @@ -184,6 +207,10 @@ paths := []string{} for _, decodedDependencyBlock := range decodedDependencyBlocks { + // skip dependency if is not enabled + if !decodedDependencyBlock.isEnabled() { + continue + } paths = append(paths, decodedDependencyBlock.ConfigPath) } @@ -274,6 +301,9 @@ dependencyErrGroup, _ := errgroup.WithContext(context.Background()) for _, dependencyConfig := range dependencyConfigs { + if !dependencyConfig.isEnabled() { + continue + } dependencyConfig := dependencyConfig // https://golang.org/doc/faq#closures_and_goroutines dependencyErrGroup.Go(func() error { // Loose struct to hold the attributes of the dependency. This includes: @@ -325,6 +355,9 @@ // If the dependency block indicates a mock_outputs_merge_strategy_with_state attribute, mock_outputs and state outputs will be merged following the merge strategy // - If the dependency block does NOT indicate a mock_outputs attribute, this will return an error. func getTerragruntOutputIfAppliedElseConfiguredDefault(dependencyConfig Dependency, terragruntOptions *options.TerragruntOptions) (*cty.Value, error) { + if !dependencyConfig.isEnabled() { + return nil, nil + } if dependencyConfig.shouldGetOutputs() { outputVal, isEmpty, err := getTerragruntOutput(dependencyConfig, terragruntOptions) if err != nil { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.16/config/dependency_test.go new/terragrunt-0.50.17/config/dependency_test.go --- old/terragrunt-0.50.16/config/dependency_test.go 2023-09-13 15:55:15.000000000 +0200 +++ new/terragrunt-0.50.17/config/dependency_test.go 2023-09-14 20:36:41.000000000 +0200 @@ -109,3 +109,25 @@ require.NotNil(t, defaultAllowedCommands) assert.Equal(t, *defaultAllowedCommands, []string{"validate", "apply"}) } + +func TestDisabledDependency(t *testing.T) { + t.Parallel() + + config := ` +dependency "ec2" { + config_path = "../ec2" + enabled = false +} +dependency "vpc" { + config_path = "../vpc" +} +` + filename := DefaultTerragruntConfigPath + parser := hclparse.NewParser() + file, err := parseHcl(parser, config, filename) + require.NoError(t, err) + + decoded := terragruntDependency{} + require.NoError(t, decodeHcl(file, filename, &decoded, mockOptionsForTest(t), EvalContextExtensions{})) + assert.Equal(t, len(decoded.Dependencies), 2) +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.16/docs/_docs/04_reference/config-blocks-and-attributes.md new/terragrunt-0.50.17/docs/_docs/04_reference/config-blocks-and-attributes.md --- old/terragrunt-0.50.16/docs/_docs/04_reference/config-blocks-and-attributes.md 2023-09-13 15:55:15.000000000 +0200 +++ new/terragrunt-0.50.17/docs/_docs/04_reference/config-blocks-and-attributes.md 2023-09-14 20:36:41.000000000 +0200 @@ -884,6 +884,7 @@ outputs of this dependency with the expression `dependency.vpc.outputs`. - `config_path` (attribute): Path to a Terragrunt module (folder with a `terragrunt.hcl` file) that should be included as a dependency in this configuration. +- `enabled` (attribute): When `false`, excludes the dependency from execution. Defaults to `true`. - `skip_outputs` (attribute): When `true`, skip calling `terragrunt output` when processing this dependency. If `mock_outputs` is configured, set `outputs` to the value of `mock_outputs`. Otherwise, `outputs` will be set to an empty map. Put another way, setting `skip_outputs` means "use mocks all the time if `mock_outputs` are set." diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.16/test/fixture-disabled/app/terragrunt.hcl new/terragrunt-0.50.17/test/fixture-disabled/app/terragrunt.hcl --- old/terragrunt-0.50.16/test/fixture-disabled/app/terragrunt.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.50.17/test/fixture-disabled/app/terragrunt.hcl 2023-09-14 20:36:41.000000000 +0200 @@ -0,0 +1,24 @@ +dependency "m1" { + config_path = "../m1" + mock_outputs = { + "output1" = "mocked_output1" + } +} + +dependency "m2" { + config_path = "../m2" + enabled = false + + mock_outputs = { + "output2" = "mocked_output2" + } +} + +dependency "m3" { + config_path = "../m3" + enabled = true + + mock_outputs = { + "output3" = "mocked_output3" + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.16/test/fixture-disabled/m2/terragrunt.hcl new/terragrunt-0.50.17/test/fixture-disabled/m2/terragrunt.hcl --- old/terragrunt-0.50.16/test/fixture-disabled/m2/terragrunt.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.50.17/test/fixture-disabled/m2/terragrunt.hcl 2023-09-14 20:36:41.000000000 +0200 @@ -0,0 +1 @@ +broken hcl file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.16/test/integration_debug_test.go new/terragrunt-0.50.17/test/integration_debug_test.go --- old/terragrunt-0.50.16/test/integration_debug_test.go 2023-09-13 15:55:15.000000000 +0200 +++ new/terragrunt-0.50.17/test/integration_debug_test.go 2023-09-14 20:36:41.000000000 +0200 @@ -230,6 +230,7 @@ "config_path": "../dep", "outputs": nil, "mock_outputs": nil, + "enabled": nil, "mock_outputs_allowed_terraform_commands": nil, "mock_outputs_merge_strategy_with_state": nil, "mock_outputs_merge_with_state": nil, @@ -330,6 +331,7 @@ "config_path": "./baz", "outputs": nil, "mock_outputs": nil, + "enabled": nil, "mock_outputs_allowed_terraform_commands": nil, "mock_outputs_merge_strategy_with_state": nil, "mock_outputs_merge_with_state": nil, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.50.16/test/integration_test.go new/terragrunt-0.50.17/test/integration_test.go --- old/terragrunt-0.50.16/test/integration_test.go 2023-09-13 15:55:15.000000000 +0200 +++ new/terragrunt-0.50.17/test/integration_test.go 2023-09-14 20:36:41.000000000 +0200 @@ -170,6 +170,7 @@ TEST_FIXTURE_GCS_NO_PREFIX = "fixture-gcs-no-prefix/" TEST_FIXTURE_DISABLED_PATH = "fixture-disabled-path/" TEST_FIXTURE_NO_SUBMODULES = "fixture-no-submodules/" + TEST_FIXTURE_DISABLED_MODULE = "fixture-disabled/" TERRAFORM_BINARY = "terraform" TERRAFORM_FOLDER = ".terraform" TERRAFORM_STATE = "terraform.tfstate" @@ -5012,7 +5013,7 @@ assert.True(t, strings.Contains(output, strings.TrimSpace(expectedOutput))) } -func TestRenderJsonMetadataDependencies(t *testing.T) { +func TestRenderJsonMetadataDependency(t *testing.T) { t.Parallel() tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_RENDER_JSON_METADATA) @@ -5091,6 +5092,7 @@ "metadata": expectedMetadata, "value": map[string]interface{}{ "config_path": "../dependency", + "enabled": nil, "mock_outputs": map[string]interface{}{ "bastion_host_security_group_id": "123", "security_group_id": "sg-abcd1234", @@ -5262,12 +5264,14 @@ "name": "dep", "outputs": nil, "skip": nil, + "enabled": nil, }, }, "dep2": map[string]interface{}{ "metadata": terragruntMetadata, "value": map[string]interface{}{ "config_path": "../dependency2", + "enabled": nil, "mock_outputs": map[string]interface{}{ "test2": "value2", }, @@ -6033,6 +6037,25 @@ require.NotContains(t, stderr.String(), "No double-slash (//) found in source URL") } +func TestTerragruntDisabledDependency(t *testing.T) { + t.Parallel() + + tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_DISABLED_MODULE) + cleanupTerraformFolder(t, tmpEnvPath) + testPath := util.JoinPath(tmpEnvPath, TEST_FIXTURE_DISABLED_MODULE, "app") + + stdout := bytes.Buffer{} + stderr := bytes.Buffer{} + + err := runTerragruntCommand(t, fmt.Sprintf("terragrunt run-all plan --terragrunt-non-interactive --terragrunt-log-level debug --terragrunt-working-dir %s", testPath), &stdout, &stderr) + require.NoError(t, err) + // check that only enabled dependencies are evaluated + require.Contains(t, stderr.String(), util.JoinPath(tmpEnvPath, TEST_FIXTURE_DISABLED_MODULE, "app")) + require.Contains(t, stderr.String(), util.JoinPath(tmpEnvPath, TEST_FIXTURE_DISABLED_MODULE, "m1")) + require.Contains(t, stderr.String(), util.JoinPath(tmpEnvPath, TEST_FIXTURE_DISABLED_MODULE, "m3")) + require.NotContains(t, stderr.String(), util.JoinPath(tmpEnvPath, TEST_FIXTURE_DISABLED_MODULE, "m2")) +} + func validateOutput(t *testing.T, outputs map[string]TerraformOutput, key string, value interface{}) { t.Helper() output, hasPlatform := outputs[key] ++++++ terragrunt.obsinfo ++++++ --- /var/tmp/diff_new_pack.JnAWne/_old 2023-09-15 22:11:13.193459253 +0200 +++ /var/tmp/diff_new_pack.JnAWne/_new 2023-09-15 22:11:13.197459396 +0200 @@ -1,5 +1,5 @@ name: terragrunt -version: 0.50.16 -mtime: 1694613315 -commit: c0e6eddb0715912ca5402da581356761b1243fdb +version: 0.50.17 +mtime: 1694716601 +commit: b9b239dca970724b121b7be636a8196446beb9de ++++++ 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