From 60dc6606df235347f9aa8efc45a2c8929478151e Mon Sep 17 00:00:00 2001 From: TJ Hoplock Date: Sat, 22 Jun 2024 00:55:51 -0400 Subject: [PATCH] fix(manager): don't shadow module test script exit code This was redeclaring the `testRC` var defined in the outer scope. The `err` var already exists in this scope from the prior calls, so both of these vars can be updated to just assignment, no declaration needed (and thus no shadowing). This preserves the test script's exit code, rather than always returning 0 because it was in the wrong scope. --- internal/manager/module.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/manager/module.go b/internal/manager/module.go index 409c0b9..5387fc1 100644 --- a/internal/manager/module.go +++ b/internal/manager/module.go @@ -144,7 +144,7 @@ func (mgr *Manager) RunModule(ctx context.Context, logger *slog.Logger, mod Modu return fmt.Errorf("Failed to template script: %s", err) } - testRC, err := shell.Run(ctx, runID, mod.m.Test, renderedTest, allVars) + testRC, err = shell.Run(ctx, runID, mod.m.Test, renderedTest, allVars) switch { case err != nil: // if test script for a module fails, log a warning for user and continue with apply