Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: TF output log level #3646

Merged
merged 3 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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