Skip to content

Commit

Permalink
fix: TF output log level (#3646)
Browse files Browse the repository at this point in the history
* fix: output level

* fix: output level

* fix: strict-lint
  • Loading branch information
levkohimins authored Dec 11, 2024
1 parent 160f183 commit 9b3ef3e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion configstack/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func FindWhereWorkingDirIsIncluded(ctx context.Context, opts *options.Terragrunt
cfgOptions.OriginalTerragruntConfigPath = opts.OriginalTerragruntConfigPath
cfgOptions.TerraformCommand = opts.TerraformCommand
cfgOptions.NonInteractive = true
cfgOptions.Logger = opts.Logger.WithOptions(log.WithHooks(NewForceLogLevelHook(log.DebugLevel)))
cfgOptions.Logger = cfgOptions.Logger.WithOptions(log.WithHooks(NewForceLogLevelHook(log.DebugLevel)))

// build stack from config directory
stack, err := FindStackInSubfolders(ctx, cfgOptions, WithChildTerragruntConfig(terragruntConfig))
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/log/levels/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "text" {
value = "output"
}
1 change: 1 addition & 0 deletions test/fixtures/log/levels/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Intentionally empty
21 changes: 21 additions & 0 deletions test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const (
testFixtureInputs = "fixtures/inputs"
testFixtureInputsFromDependency = "fixtures/inputs-from-dependency"
testFixtureLogFormatter = "fixtures/log/formatter"
testFixtureLogStdoutLevel = "fixtures/log/levels"
testFixtureLogRelPaths = "fixtures/log/rel-paths"
testFixtureMissingDependence = "fixtures/missing-dependencies/main"
testFixtureModulePathError = "fixtures/module-path-in-error"
Expand Down Expand Up @@ -360,6 +361,26 @@ func TestLogFormatPrettyOutput(t *testing.T) {
assert.Contains(t, stderr, "DEBUG Terragrunt Version:")
}

func TestLogStdoutLevel(t *testing.T) {
t.Parallel()

helpers.CleanupTerraformFolder(t, testFixtureLogStdoutLevel)
tmpEnvPath := helpers.CopyEnvironment(t, testFixtureLogStdoutLevel)
rootPath := util.JoinPath(tmpEnvPath, testFixtureLogStdoutLevel)

stdout, stderr, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt apply -auto-approve --terragrunt-log-level trace --terragrunt-non-interactive -no-color --terragrunt-no-color --terragrunt-log-format=pretty --terragrunt-working-dir "+rootPath)
require.NoError(t, err)

assert.Empty(t, stdout)
assert.Contains(t, stderr, "STDOUT "+wrappedBinary()+": Changes to Outputs")

stdout, stderr, err = helpers.RunTerragruntCommandWithOutput(t, "terragrunt destroy -auto-approve --terragrunt-log-level trace --terragrunt-non-interactive -no-color --terragrunt-no-color --terragrunt-log-format=pretty --terragrunt-working-dir "+rootPath)
require.NoError(t, err)

assert.Empty(t, stdout)
assert.Contains(t, stderr, "STDOUT "+wrappedBinary()+": Changes to Outputs")
}

func TestLogFormatKeyValueOutput(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 9b3ef3e

Please sign in to comment.