Exit Code Propagation (#1655)

* exit codes of failed RUN commands may now be propagated to the caller by using the --propagate-exit-code flag

* removed exit code propagation flag; the exit function now unwraps the error and looks for an exit code

* added integration test for exit code propagation

* added trailing new line in test Dockerfile_exit_code_propagation; tidying up README.md removing all traces of error propagation flag

* moved exit code propagation test to integration_test.go; moved exit code propagation test files to 'testdata' to avoid interference with other integration tests
This commit is contained in:
Benjamin Krenn
2021-06-01 10:43:49 -07:00
committed by GitHub
parent 7b6495426d
commit 57ea150cad
3 changed files with 75 additions and 1 deletions
+13 -1
View File
@@ -19,6 +19,7 @@ package cmd
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"regexp"
"strings"
@@ -340,8 +341,19 @@ func resolveRelativePaths() error {
}
func exit(err error) {
var execErr *exec.ExitError
if errors.As(err, &execErr) {
// if there is an exit code propagate it
exitWithCode(err, execErr.ExitCode())
}
// otherwise exit with catch all 1
exitWithCode(err, 1)
}
//exits with the given error and exit code
func exitWithCode(err error, exitCode int) {
fmt.Println(err)
os.Exit(1)
os.Exit(exitCode)
}
func isURL(path string) bool {