diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-12-17 13:16:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-17 13:16:23 +0100 |
commit | 820cf0e0661764de4e61e3d27a603acec817a363 (patch) | |
tree | 590b0a9811d1bc923385ab4ad4309b067af69ba4 /cmd/podman/images/build.go | |
parent | c9a3f4ec44c4507c0a801635b93d840723826b7a (diff) | |
parent | 6423174c67d486522354806bf326c843c07d18c1 (diff) | |
download | podman-820cf0e0661764de4e61e3d27a603acec817a363.tar.gz podman-820cf0e0661764de4e61e3d27a603acec817a363.tar.bz2 podman-820cf0e0661764de4e61e3d27a603acec817a363.zip |
Merge pull request #12622 from flouthoc/return_exit_code_for_build
build: relay `exitcode` from imagebuildah to registry
Diffstat (limited to 'cmd/podman/images/build.go')
-rw-r--r-- | cmd/podman/images/build.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go index 4c563ed27..751db099f 100644 --- a/cmd/podman/images/build.go +++ b/cmd/podman/images/build.go @@ -1,9 +1,11 @@ package images import ( + "fmt" "io" "io/ioutil" "os" + "os/exec" "path/filepath" "strings" "time" @@ -289,7 +291,23 @@ func build(cmd *cobra.Command, args []string) error { } report, err := registry.ImageEngine().Build(registry.GetContext(), containerFiles, *apiBuildOpts) + if err != nil { + exitCode := buildahCLI.ExecErrorCodeGeneric + if registry.IsRemote() { + // errors from server does not contain ExitCode + // so parse exit code from error message + remoteExitCode, parseErr := utils.ExitCodeFromBuildError(fmt.Sprint(errors.Cause(err))) + if parseErr == nil { + exitCode = remoteExitCode + } + } + + if ee, ok := (errors.Cause(err)).(*exec.ExitError); ok { + exitCode = ee.ExitCode() + } + + registry.SetExitCode(exitCode) return err } |