From 2ce37f160d8e69f67cb1760344227776853c1456 Mon Sep 17 00:00:00 2001 From: Levko Burburas Date: Thu, 21 Nov 2024 16:17:53 +0200 Subject: [PATCH 1/3] chore: detailed exit code implementation --- main.go | 24 +++--- shell/context.go | 19 ++++- shell/detailed_exitcode.go | 39 +++++++++ shell/run_shell_cmd.go | 15 +++- terraform/terraform.go | 11 +-- .../detailed-exitcode/changes/app1/main.tf | 4 + .../changes/app1/terragrunt.hcl | 1 + .../detailed-exitcode/changes/app2/main.tf | 4 + .../changes/app2/terragrunt.hcl | 1 + .../detailed-exitcode/error/app1/main.tf | 3 + .../error/app1/terragrunt.hcl | 1 + .../detailed-exitcode/error/app2/main.tf | 4 + .../error/app2/terragrunt.hcl | 1 + test/helpers/package.go | 22 +++-- test/integration_test.go | 81 +++++++++++++++++++ 15 files changed, 209 insertions(+), 21 deletions(-) create mode 100644 shell/detailed_exitcode.go create mode 100644 test/fixtures/detailed-exitcode/changes/app1/main.tf create mode 100644 test/fixtures/detailed-exitcode/changes/app1/terragrunt.hcl create mode 100644 test/fixtures/detailed-exitcode/changes/app2/main.tf create mode 100644 test/fixtures/detailed-exitcode/changes/app2/terragrunt.hcl create mode 100644 test/fixtures/detailed-exitcode/error/app1/main.tf create mode 100644 test/fixtures/detailed-exitcode/error/app1/terragrunt.hcl create mode 100644 test/fixtures/detailed-exitcode/error/app2/main.tf create mode 100644 test/fixtures/detailed-exitcode/error/app2/terragrunt.hcl diff --git a/main.go b/main.go index d1e5c1d3b9..9421eeb177 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "os" "github.com/gruntwork-io/terragrunt/cli" @@ -14,30 +15,35 @@ import ( // The main entrypoint for Terragrunt func main() { + var exitCode shell.DetailedExitCode + + ctx := context.Background() + ctx = shell.ContextWithDetailedExitCode(ctx, &exitCode) + opts := options.NewTerragruntOptions() parseAndSetLogEnvs(opts) - defer errors.Recover(checkForErrorsAndExit(opts.Logger)) + defer errors.Recover(checkForErrorsAndExit(opts.Logger, exitCode.Get())) app := cli.NewApp(opts) - err := app.Run(os.Args) + err := app.RunContext(ctx, os.Args) - checkForErrorsAndExit(opts.Logger)(err) + checkForErrorsAndExit(opts.Logger, exitCode.Get())(err) } // If there is an error, display it in the console and exit with a non-zero exit code. Otherwise, exit 0. -func checkForErrorsAndExit(logger log.Logger) func(error) { +func checkForErrorsAndExit(logger log.Logger, exitCode int) func(error) { return func(err error) { if err == nil { - os.Exit(0) + os.Exit(exitCode) } else { logger.Error(err.Error()) logger.Debug(errors.ErrorStack(err)) // exit with the underlying error code - exitCode, exitCodeErr := util.GetExitCode(err) + exitCoder, exitCodeErr := util.GetExitCode(err) if exitCodeErr != nil { - exitCode = 1 + exitCoder = 1 logger.Errorf("Unable to determine underlying exit code, so Terragrunt will exit with error code 1") } @@ -46,7 +52,7 @@ func checkForErrorsAndExit(logger log.Logger) func(error) { logger.Errorf("Suggested fixes: \n%s", explain) } - os.Exit(exitCode) + os.Exit(exitCoder) } } } @@ -56,7 +62,7 @@ func parseAndSetLogEnvs(opts *options.TerragruntOptions) { level, err := log.ParseLevel(levelStr) if err != nil { err := errors.Errorf("Could not parse log level from environment variable %s=%s, %w", commands.TerragruntLogLevelEnvName, levelStr, err) - checkForErrorsAndExit(opts.Logger)(err) + checkForErrorsAndExit(opts.Logger, 0)(err) } opts.Logger.SetOptions(log.WithLevel(level)) diff --git a/shell/context.go b/shell/context.go index 14008e04e4..a4315eadc7 100644 --- a/shell/context.go +++ b/shell/context.go @@ -12,7 +12,8 @@ import ( const ( TerraformCommandContextKey ctxKey = iota - RunCmdCacheContextKey ctxKey = iota + RunCmdCacheContextKey + DetailedExitCodeContextKey runCmdCacheName = "runCmdCache" ) @@ -37,3 +38,19 @@ func TerraformCommandHookFromContext(ctx context.Context) RunShellCommandFunc { return nil } + +// ContextWithDetailedExitCode returns a new context containing the given DetailedExitCode. +func ContextWithDetailedExitCode(ctx context.Context, detailedExitCode *DetailedExitCode) context.Context { + return context.WithValue(ctx, DetailedExitCodeContextKey, detailedExitCode) +} + +// DetailedExitCodeFromContext returns DetailedExitCode if the give context contains it. +func DetailedExitCodeFromContext(ctx context.Context) *DetailedExitCode { + if val := ctx.Value(DetailedExitCodeContextKey); val != nil { + if val, ok := val.(*DetailedExitCode); ok { + return val + } + } + + return nil +} diff --git a/shell/detailed_exitcode.go b/shell/detailed_exitcode.go new file mode 100644 index 0000000000..d9ac02bc49 --- /dev/null +++ b/shell/detailed_exitcode.go @@ -0,0 +1,39 @@ +package shell + +import ( + "sync" +) + +const ( + DetailedExitCodeNoChanges int = iota + DetailedExitCodeError + DetailedExitCodeChangesPresent +) + +// DetailedExitCode is the TF detailed exit code. https://opentofu.org/docs/cli/commands/plan/ +type DetailedExitCode struct { + Code int + mu sync.RWMutex +} + +// Get returns exit code. +func (coder *DetailedExitCode) Get() int { + coder.mu.RLock() + defer coder.mu.RUnlock() + + return coder.Code +} + +// Set sets the newCode if the previous value is not 1 and the new value is greater than the previous one. +func (coder *DetailedExitCode) Set(newCode int) { + coder.mu.Lock() + defer coder.mu.Unlock() + + if coder.Code == DetailedExitCodeError { + return + } + + if coder.Code < newCode || newCode == DetailedExitCodeError { + coder.Code = newCode + } +} diff --git a/shell/run_shell_cmd.go b/shell/run_shell_cmd.go index 8280f15dfc..c6c48b98bd 100644 --- a/shell/run_shell_cmd.go +++ b/shell/run_shell_cmd.go @@ -69,7 +69,20 @@ func RunTerraformCommandWithOutput(ctx context.Context, opts *options.Terragrunt return nil, err } - return RunShellCommandWithOutput(ctx, opts, "", false, needsPTY, opts.TerraformPath, args...) + output, err := RunShellCommandWithOutput(ctx, opts, "", false, needsPTY, opts.TerraformPath, args...) + + if err != nil && util.ListContainsElement(args, terraform.FlagNameDetailedExitCode) { + code, _ := util.GetExitCode(err) + if exitCode := DetailedExitCodeFromContext(ctx); exitCode != nil { + exitCode.Set(code) + } + + if code != 1 { + return output, nil + } + } + + return output, err } // RunShellCommand runs the given shell command. diff --git a/terraform/terraform.go b/terraform/terraform.go index 757dc77666..a90aaedd7f 100644 --- a/terraform/terraform.go +++ b/terraform/terraform.go @@ -25,11 +25,12 @@ const ( CommandNameShow = "show" CommandNameVersion = "version" - FlagNameHelpLong = "-help" - FlagNameHelpShort = "-h" - FlagNameVersion = "-version" - FlagNameJSON = "-json" - FlagNameNoColor = "-no-color" + FlagNameDetailedExitCode = "-detailed-exitcode" + FlagNameHelpLong = "-help" + FlagNameHelpShort = "-h" + FlagNameVersion = "-version" + FlagNameJSON = "-json" + FlagNameNoColor = "-no-color" // `apply -destroy` is alias for `destroy` FlagNameDestroy = "-destroy" diff --git a/test/fixtures/detailed-exitcode/changes/app1/main.tf b/test/fixtures/detailed-exitcode/changes/app1/main.tf new file mode 100644 index 0000000000..83f596d60a --- /dev/null +++ b/test/fixtures/detailed-exitcode/changes/app1/main.tf @@ -0,0 +1,4 @@ +resource "local_file" "example" { + content = "Test" + filename = "${path.module}/example.txt" +} diff --git a/test/fixtures/detailed-exitcode/changes/app1/terragrunt.hcl b/test/fixtures/detailed-exitcode/changes/app1/terragrunt.hcl new file mode 100644 index 0000000000..bb7b160deb --- /dev/null +++ b/test/fixtures/detailed-exitcode/changes/app1/terragrunt.hcl @@ -0,0 +1 @@ +# Intentionally empty diff --git a/test/fixtures/detailed-exitcode/changes/app2/main.tf b/test/fixtures/detailed-exitcode/changes/app2/main.tf new file mode 100644 index 0000000000..83f596d60a --- /dev/null +++ b/test/fixtures/detailed-exitcode/changes/app2/main.tf @@ -0,0 +1,4 @@ +resource "local_file" "example" { + content = "Test" + filename = "${path.module}/example.txt" +} diff --git a/test/fixtures/detailed-exitcode/changes/app2/terragrunt.hcl b/test/fixtures/detailed-exitcode/changes/app2/terragrunt.hcl new file mode 100644 index 0000000000..bb7b160deb --- /dev/null +++ b/test/fixtures/detailed-exitcode/changes/app2/terragrunt.hcl @@ -0,0 +1 @@ +# Intentionally empty diff --git a/test/fixtures/detailed-exitcode/error/app1/main.tf b/test/fixtures/detailed-exitcode/error/app1/main.tf new file mode 100644 index 0000000000..f76d108563 --- /dev/null +++ b/test/fixtures/detailed-exitcode/error/app1/main.tf @@ -0,0 +1,3 @@ +data "local_file" "read_not_existing_file" { + filename = "${path.module}/not-existing-file.txt" +} diff --git a/test/fixtures/detailed-exitcode/error/app1/terragrunt.hcl b/test/fixtures/detailed-exitcode/error/app1/terragrunt.hcl new file mode 100644 index 0000000000..bb7b160deb --- /dev/null +++ b/test/fixtures/detailed-exitcode/error/app1/terragrunt.hcl @@ -0,0 +1 @@ +# Intentionally empty diff --git a/test/fixtures/detailed-exitcode/error/app2/main.tf b/test/fixtures/detailed-exitcode/error/app2/main.tf new file mode 100644 index 0000000000..83f596d60a --- /dev/null +++ b/test/fixtures/detailed-exitcode/error/app2/main.tf @@ -0,0 +1,4 @@ +resource "local_file" "example" { + content = "Test" + filename = "${path.module}/example.txt" +} diff --git a/test/fixtures/detailed-exitcode/error/app2/terragrunt.hcl b/test/fixtures/detailed-exitcode/error/app2/terragrunt.hcl new file mode 100644 index 0000000000..bb7b160deb --- /dev/null +++ b/test/fixtures/detailed-exitcode/error/app2/terragrunt.hcl @@ -0,0 +1 @@ +# Intentionally empty diff --git a/test/helpers/package.go b/test/helpers/package.go index 84ead2650f..96c2734e4a 100644 --- a/test/helpers/package.go +++ b/test/helpers/package.go @@ -720,7 +720,7 @@ func RemoveFolder(t *testing.T, path string) { } } -func RunTerragruntCommand(t *testing.T, command string, writer io.Writer, errwriter io.Writer) error { +func RunTerragruntCommandWithContext(t *testing.T, ctx context.Context, command string, writer io.Writer, errwriter io.Writer) error { t.Helper() args := splitCommand(command) @@ -732,9 +732,15 @@ func RunTerragruntCommand(t *testing.T, command string, writer io.Writer, errwri t.Log(args) opts := options.NewTerragruntOptionsWithWriters(writer, errwriter) - app := cli.NewApp(opts) + app := cli.NewApp(opts) //nolint:contextcheck + + return app.RunContext(ctx, args) +} + +func RunTerragruntCommand(t *testing.T, command string, writer io.Writer, errwriter io.Writer) error { + t.Helper() - return app.Run(args) + return RunTerragruntCommandWithContext(t, context.Background(), command, writer, errwriter) } func RunTerragruntVersionCommand(t *testing.T, ver string, command string, writer io.Writer, errwriter io.Writer) error { @@ -761,18 +767,24 @@ func LogBufferContentsLineByLine(t *testing.T, out bytes.Buffer, label string) { } } -func RunTerragruntCommandWithOutput(t *testing.T, command string) (string, string, error) { +func RunTerragruntCommandWithOutputWithContext(t *testing.T, ctx context.Context, command string) (string, string, error) { t.Helper() stdout := bytes.Buffer{} stderr := bytes.Buffer{} - err := RunTerragruntCommand(t, command, &stdout, &stderr) + err := RunTerragruntCommandWithContext(t, ctx, command, &stdout, &stderr) LogBufferContentsLineByLine(t, stdout, "stdout") LogBufferContentsLineByLine(t, stderr, "stderr") return stdout.String(), stderr.String(), err } +func RunTerragruntCommandWithOutput(t *testing.T, command string) (string, string, error) { + t.Helper() + + return RunTerragruntCommandWithOutputWithContext(t, context.Background(), command) +} + func RunTerragruntRedirectOutput(t *testing.T, command string, writer io.Writer, errwriter io.Writer) { t.Helper() diff --git a/test/integration_test.go b/test/integration_test.go index 56ac533199..97dd3f2346 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -3,6 +3,7 @@ package test_test import ( "bytes" + "context" "encoding/json" "fmt" "os" @@ -98,6 +99,7 @@ const ( testFixtureErrorPrint = "fixtures/error-print" testFixtureBufferModuleOutput = "fixtures/buffer-module-output" testFixtureDependenciesOptimisation = "fixtures/dependency-optimisation" + testFixtureDetailedExitCode = "fixtures/detailed-exitcode" terraformFolder = ".terraform" @@ -107,6 +109,85 @@ const ( terragruntCache = ".terragrunt-cache" ) +func TestDetailedExitCodeError(t *testing.T) { + t.Parallel() + + testFixturePath := filepath.Join(testFixtureDetailedExitCode, "error") + + helpers.CleanupTerraformFolder(t, testFixturePath) + tmpEnvPath := helpers.CopyEnvironment(t, testFixturePath) + rootPath := util.JoinPath(tmpEnvPath, testFixturePath) + + var exitCode shell.DetailedExitCode + ctx := context.Background() + ctx = shell.ContextWithDetailedExitCode(ctx, &exitCode) + + _, stderr, err := helpers.RunTerragruntCommandWithOutputWithContext(t, ctx, "terragrunt run-all plan --terragrunt-log-level debug --terragrunt-non-interactive -detailed-exitcode --terragrunt-working-dir "+rootPath) + require.Error(t, err) + require.Contains(t, stderr, "not-existing-file.txt: no such file or directory") + require.Equal(t, 1, exitCode.Get()) +} + +func TestDetailedExitCodeChangesPresentAll(t *testing.T) { + t.Parallel() + + testFixturePath := filepath.Join(testFixtureDetailedExitCode, "changes") + + helpers.CleanupTerraformFolder(t, testFixturePath) + tmpEnvPath := helpers.CopyEnvironment(t, testFixturePath) + rootPath := util.JoinPath(tmpEnvPath, testFixturePath) + + var exitCode shell.DetailedExitCode + ctx := context.Background() + ctx = shell.ContextWithDetailedExitCode(ctx, &exitCode) + + _, _, err := helpers.RunTerragruntCommandWithOutputWithContext(t, ctx, "terragrunt run-all plan --terragrunt-log-level debug --terragrunt-non-interactive -detailed-exitcode --terragrunt-working-dir "+rootPath) + require.NoError(t, err) + require.Equal(t, 2, exitCode.Get()) +} + +func TestDetailedExitCodeChangesPresentOne(t *testing.T) { + t.Parallel() + + testFixturePath := filepath.Join(testFixtureDetailedExitCode, "changes") + + helpers.CleanupTerraformFolder(t, testFixturePath) + tmpEnvPath := helpers.CopyEnvironment(t, testFixturePath) + rootPath := util.JoinPath(tmpEnvPath, testFixturePath) + + var exitCode shell.DetailedExitCode + ctx := context.Background() + ctx = shell.ContextWithDetailedExitCode(ctx, &exitCode) + + _, _, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt run-all apply --terragrunt-log-level debug --terragrunt-non-interactive --terragrunt-working-dir "+filepath.Join(rootPath, "app1")) + require.NoError(t, err) + + _, _, err = helpers.RunTerragruntCommandWithOutputWithContext(t, ctx, "terragrunt run-all plan --terragrunt-log-level debug --terragrunt-non-interactive -detailed-exitcode --terragrunt-working-dir "+rootPath) + require.NoError(t, err) + require.Equal(t, 2, exitCode.Get()) +} + +func TestDetailedExitCodeNoChanges(t *testing.T) { + t.Parallel() + + testFixturePath := filepath.Join(testFixtureDetailedExitCode, "changes") + + helpers.CleanupTerraformFolder(t, testFixturePath) + tmpEnvPath := helpers.CopyEnvironment(t, testFixturePath) + rootPath := util.JoinPath(tmpEnvPath, testFixturePath) + + var exitCode shell.DetailedExitCode + ctx := context.Background() + ctx = shell.ContextWithDetailedExitCode(ctx, &exitCode) + + _, _, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt run-all apply --terragrunt-log-level debug --terragrunt-non-interactive --terragrunt-working-dir "+rootPath) + require.NoError(t, err) + + _, _, err = helpers.RunTerragruntCommandWithOutputWithContext(t, ctx, "terragrunt run-all plan --terragrunt-log-level debug --terragrunt-non-interactive -detailed-exitcode --terragrunt-working-dir "+rootPath) + require.NoError(t, err) + require.Equal(t, 0, exitCode.Get()) +} + func TestLogCustomFormatOutput(t *testing.T) { t.Parallel() From 18a7ef6434313a2ba938cba6441828c8748d3e04 Mon Sep 17 00:00:00 2001 From: Levko Burburas Date: Thu, 21 Nov 2024 16:28:01 +0200 Subject: [PATCH 2/3] chore: remove old test --- test/fixtures/exit-code/main.tf | 1 - test/fixtures/exit-code/terragrunt.hcl | 1 - test/integration_test.go | 15 --------------- 3 files changed, 17 deletions(-) delete mode 100644 test/fixtures/exit-code/main.tf delete mode 100644 test/fixtures/exit-code/terragrunt.hcl diff --git a/test/fixtures/exit-code/main.tf b/test/fixtures/exit-code/main.tf deleted file mode 100644 index 037e3518a1..0000000000 --- a/test/fixtures/exit-code/main.tf +++ /dev/null @@ -1 +0,0 @@ -resource "null_resource" "foo" {} \ No newline at end of file diff --git a/test/fixtures/exit-code/terragrunt.hcl b/test/fixtures/exit-code/terragrunt.hcl deleted file mode 100644 index 48ddb6fcc9..0000000000 --- a/test/fixtures/exit-code/terragrunt.hcl +++ /dev/null @@ -1 +0,0 @@ -# Intentionally empty \ No newline at end of file diff --git a/test/integration_test.go b/test/integration_test.go index 97dd3f2346..a39608b596 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -50,7 +50,6 @@ const ( testFixtureEmptyState = "fixtures/empty-state/" testFixtureEnvVarsBlockPath = "fixtures/env-vars-block/" testFixtureExcludesFile = "fixtures/excludes-file" - testFixtureExitCode = "fixtures/exit-code" testFixtureExternalDependence = "fixtures/external-dependencies" testFixtureExternalDependency = "fixtures/external-dependency/" testFixtureExtraArgsPath = "fixtures/extra-args/" @@ -876,20 +875,6 @@ func TestInvalidSource(t *testing.T) { assert.True(t, ok) } -// Run terragrunt plan -detailed-exitcode on a folder with some uncreated resources and make sure that you get an exit -// code of "2", which means there are changes to apply. -func TestExitCode(t *testing.T) { - t.Parallel() - - rootPath := helpers.CopyEnvironment(t, testFixtureExitCode) - modulePath := util.JoinPath(rootPath, testFixtureExitCode) - err := helpers.RunTerragruntCommand(t, "terragrunt plan -detailed-exitcode --terragrunt-non-interactive --terragrunt-working-dir "+modulePath, os.Stdout, os.Stderr) - - exitCode, exitCodeErr := util.GetExitCode(err) - require.NoError(t, exitCodeErr) - assert.Equal(t, 2, exitCode) -} - func TestPlanfileOrder(t *testing.T) { t.Parallel() From 54bb6f06483b216c7e049d1a5d5ec33a2ca4bfae Mon Sep 17 00:00:00 2001 From: Levko Burburas Date: Thu, 21 Nov 2024 17:25:13 +0200 Subject: [PATCH 3/3] chore: fix tests --- shell/detailed_exitcode.go | 4 +--- test/fixtures/detailed-exitcode/changes/app1/main.tf | 2 +- test/fixtures/detailed-exitcode/changes/app2/main.tf | 2 +- test/fixtures/detailed-exitcode/error/app2/main.tf | 2 +- test/integration_test.go | 10 +++++----- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/shell/detailed_exitcode.go b/shell/detailed_exitcode.go index d9ac02bc49..b380a609e8 100644 --- a/shell/detailed_exitcode.go +++ b/shell/detailed_exitcode.go @@ -5,9 +5,7 @@ import ( ) const ( - DetailedExitCodeNoChanges int = iota - DetailedExitCodeError - DetailedExitCodeChangesPresent + DetailedExitCodeError = 1 ) // DetailedExitCode is the TF detailed exit code. https://opentofu.org/docs/cli/commands/plan/ diff --git a/test/fixtures/detailed-exitcode/changes/app1/main.tf b/test/fixtures/detailed-exitcode/changes/app1/main.tf index 83f596d60a..5d64b5441f 100644 --- a/test/fixtures/detailed-exitcode/changes/app1/main.tf +++ b/test/fixtures/detailed-exitcode/changes/app1/main.tf @@ -1,4 +1,4 @@ resource "local_file" "example" { - content = "Test" + content = "Test" filename = "${path.module}/example.txt" } diff --git a/test/fixtures/detailed-exitcode/changes/app2/main.tf b/test/fixtures/detailed-exitcode/changes/app2/main.tf index 83f596d60a..5d64b5441f 100644 --- a/test/fixtures/detailed-exitcode/changes/app2/main.tf +++ b/test/fixtures/detailed-exitcode/changes/app2/main.tf @@ -1,4 +1,4 @@ resource "local_file" "example" { - content = "Test" + content = "Test" filename = "${path.module}/example.txt" } diff --git a/test/fixtures/detailed-exitcode/error/app2/main.tf b/test/fixtures/detailed-exitcode/error/app2/main.tf index 83f596d60a..5d64b5441f 100644 --- a/test/fixtures/detailed-exitcode/error/app2/main.tf +++ b/test/fixtures/detailed-exitcode/error/app2/main.tf @@ -1,4 +1,4 @@ resource "local_file" "example" { - content = "Test" + content = "Test" filename = "${path.module}/example.txt" } diff --git a/test/integration_test.go b/test/integration_test.go index a39608b596..5ae1323bf0 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -123,8 +123,8 @@ func TestDetailedExitCodeError(t *testing.T) { _, stderr, err := helpers.RunTerragruntCommandWithOutputWithContext(t, ctx, "terragrunt run-all plan --terragrunt-log-level debug --terragrunt-non-interactive -detailed-exitcode --terragrunt-working-dir "+rootPath) require.Error(t, err) - require.Contains(t, stderr, "not-existing-file.txt: no such file or directory") - require.Equal(t, 1, exitCode.Get()) + assert.Contains(t, stderr, "not-existing-file.txt: no such file or directory") + assert.Equal(t, 1, exitCode.Get()) } func TestDetailedExitCodeChangesPresentAll(t *testing.T) { @@ -142,7 +142,7 @@ func TestDetailedExitCodeChangesPresentAll(t *testing.T) { _, _, err := helpers.RunTerragruntCommandWithOutputWithContext(t, ctx, "terragrunt run-all plan --terragrunt-log-level debug --terragrunt-non-interactive -detailed-exitcode --terragrunt-working-dir "+rootPath) require.NoError(t, err) - require.Equal(t, 2, exitCode.Get()) + assert.Equal(t, 2, exitCode.Get()) } func TestDetailedExitCodeChangesPresentOne(t *testing.T) { @@ -163,7 +163,7 @@ func TestDetailedExitCodeChangesPresentOne(t *testing.T) { _, _, err = helpers.RunTerragruntCommandWithOutputWithContext(t, ctx, "terragrunt run-all plan --terragrunt-log-level debug --terragrunt-non-interactive -detailed-exitcode --terragrunt-working-dir "+rootPath) require.NoError(t, err) - require.Equal(t, 2, exitCode.Get()) + assert.Equal(t, 2, exitCode.Get()) } func TestDetailedExitCodeNoChanges(t *testing.T) { @@ -184,7 +184,7 @@ func TestDetailedExitCodeNoChanges(t *testing.T) { _, _, err = helpers.RunTerragruntCommandWithOutputWithContext(t, ctx, "terragrunt run-all plan --terragrunt-log-level debug --terragrunt-non-interactive -detailed-exitcode --terragrunt-working-dir "+rootPath) require.NoError(t, err) - require.Equal(t, 0, exitCode.Get()) + assert.Equal(t, 0, exitCode.Get()) } func TestLogCustomFormatOutput(t *testing.T) {