From 21661e0a526e711dc5d46f7969fae064991ba5f0 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 23 Apr 2024 09:01:29 -0500 Subject: [PATCH] Fix shell errors not logged properly during syncs --- synchers/syncutils.go | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/synchers/syncutils.go b/synchers/syncutils.go index 7020715..83c9cdc 100644 --- a/synchers/syncutils.go +++ b/synchers/syncutils.go @@ -131,20 +131,21 @@ func SyncRunSourceCommand(remoteEnvironment Environment, syncer Syncer, dryRun b if !dryRun { if remoteEnvironment.EnvironmentName == LOCAL_ENVIRONMENT_NAME { - err, response, errstring := utils.Shellout(execString) + err, outstring, errstring := utils.Shellout(execString) if err != nil { - log.Printf(errstring) + if errstring != "" { + utils.LogError(errstring, nil) + } return err } - if response != "" && debug == false { - log.Println(response) - } + utils.LogDebugInfo(outstring, nil) } else { err, output := utils.RemoteShellout(execString, remoteEnvironment.GetOpenshiftProjectName(), sshOptions.Host, sshOptions.Port, sshOptions.PrivateKey, sshOptions.SkipAgent) - utils.LogDebugInfo(output, nil) if err != nil { - utils.LogFatalError("Unable to exec remote command: "+err.Error(), nil) + utils.LogError(output, nil) return err + } else { + utils.LogDebugInfo(output, nil) } } } @@ -287,17 +288,21 @@ func SyncRunTargetCommand(targetEnvironment Environment, syncer Syncer, dryRun b utils.LogExecutionStep(fmt.Sprintf("Running the following for target (%s)", targetEnvironment.EnvironmentName), execString) if !dryRun { if targetEnvironment.EnvironmentName == LOCAL_ENVIRONMENT_NAME { - err, _, errstring := utils.Shellout(execString) + err, outstring, errstring := utils.Shellout(execString) if err != nil { - utils.LogFatalError(errstring, nil) + if errstring != "" { + utils.LogError(errstring, nil) + } return err } + utils.LogDebugInfo(outstring, nil) } else { err, output := utils.RemoteShellout(execString, targetEnvironment.GetOpenshiftProjectName(), sshOptions.Host, sshOptions.Port, sshOptions.PrivateKey, sshOptions.SkipAgent) - utils.LogDebugInfo(output, nil) if err != nil { - utils.LogFatalError("Unable to exec remote command: "+err.Error(), nil) + utils.LogError(output, nil) return err + } else { + utils.LogDebugInfo(output, nil) } } }