diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-11-29 12:22:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-29 12:22:58 +0100 |
commit | 7f53178a7dc7cfa947896f61a3198cc6e8759eda (patch) | |
tree | 32571d79fdf2a48ef7de77f15f7a31889c1a769a /libpod/oci_util.go | |
parent | 1c0356ee919d7ad316e200171ff974e68d713789 (diff) | |
parent | bc485bce47f55135d6ead80537bc145edb779ae9 (diff) | |
download | podman-7f53178a7dc7cfa947896f61a3198cc6e8759eda.tar.gz podman-7f53178a7dc7cfa947896f61a3198cc6e8759eda.tar.bz2 podman-7f53178a7dc7cfa947896f61a3198cc6e8759eda.zip |
Merge pull request #4576 from giuseppe/oci-errors-only-match
oci: print only matching part for the errors
Diffstat (limited to 'libpod/oci_util.go')
-rw-r--r-- | libpod/oci_util.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/libpod/oci_util.go b/libpod/oci_util.go index c1a7f1c9a..3345220ac 100644 --- a/libpod/oci_util.go +++ b/libpod/oci_util.go @@ -83,11 +83,22 @@ func bindPorts(ports []ocicni.PortMapping) ([]*os.File, error) { func getOCIRuntimeError(runtimeMsg string) error { r := strings.ToLower(runtimeMsg) - if match, _ := regexp.MatchString(".*permission denied.*|.*operation not permitted.*", r); match { - return errors.Wrapf(define.ErrOCIRuntimePermissionDenied, "%s", strings.Trim(runtimeMsg, "\n")) + + includeFullOutput := logrus.GetLevel() == logrus.DebugLevel + + if match := regexp.MustCompile(".*permission denied.*|.*operation not permitted.*").FindString(r); match != "" { + errStr := match + if includeFullOutput { + errStr = runtimeMsg + } + return errors.Wrapf(define.ErrOCIRuntimePermissionDenied, "%s", strings.Trim(errStr, "\n")) } - if match, _ := regexp.MatchString(".*executable file not found in.*|.*no such file or directory.*", r); match { - return errors.Wrapf(define.ErrOCIRuntimeNotFound, "%s", strings.Trim(runtimeMsg, "\n")) + if match := regexp.MustCompile(".*executable file not found in.*|.*no such file or directory.*").FindString(r); match != "" { + errStr := match + if includeFullOutput { + errStr = runtimeMsg + } + return errors.Wrapf(define.ErrOCIRuntimeNotFound, "%s", strings.Trim(errStr, "\n")) } return errors.Wrapf(define.ErrOCIRuntime, "%s", strings.Trim(runtimeMsg, "\n")) } |