refactor: bubble up error handling so that standard exit codes can be set at the top-level

LogFail shouldn't be called internally if at all possible.
This commit is contained in:
Jose Diaz-Gonzalez
2021-02-03 04:29:57 -05:00
parent ccdbaa84f9
commit d09a7506df
26 changed files with 113 additions and 80 deletions

View File

@@ -245,14 +245,14 @@ func executeScript(appName string, image string, imageTag string, phase string)
containerID, err := createdContainerID(appName, dockerArgs, image, script, phase)
if err != nil {
common.LogFail(fmt.Sprintf("Failed to create %s execution container: %s", phase, err.Error()))
return fmt.Errorf("Failed to create %s execution container: %s", phase, err.Error())
}
if !waitForExecution(containerID) {
common.LogInfo2Quiet(fmt.Sprintf("Start of %s %s task (%s) output", appName, phaseName, containerID[0:9]))
common.LogVerboseQuietContainerLogs(containerID)
common.LogInfo2Quiet(fmt.Sprintf("End of %s %s task (%s) output", appName, phaseName, containerID[0:9]))
common.LogFail(fmt.Sprintf("Execution of %s task failed: %s", phase, phaseName))
return fmt.Errorf("Execution of %s task failed: %s", phaseName, command)
}
common.LogInfo2Quiet(fmt.Sprintf("Start of %s %s task (%s) output", appName, phaseName, containerID[0:9]))
@@ -292,7 +292,7 @@ func executeScript(appName string, image string, imageTag string, phase string)
containerCommitCmd.ShowOutput = false
containerCommitCmd.Command.Stderr = os.Stderr
if !containerCommitCmd.Execute() {
common.LogFail(fmt.Sprintf("Commiting of '%s' to image failed: %s", phase, command))
return fmt.Errorf("Commiting of '%s' to image failed: %s", phase, command)
}
return common.PlugnTrigger("scheduler-register-retired", []string{appName, containerID}...)

View File

@@ -32,7 +32,7 @@ func main() {
imageTag := flag.Arg(1)
err = appjson.TriggerPreDeploy(appName, imageTag)
default:
common.LogFail(fmt.Sprintf("Invalid plugin trigger call: %s", trigger))
err = fmt.Errorf("Invalid plugin trigger call: %s", trigger)
}
if err != nil {