summaryrefslogtreecommitdiff
path: root/libpod/define/exec_codes.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-07-24 13:16:21 +0200
committerGitHub <noreply@github.com>2019-07-24 13:16:21 +0200
commiteae9a009b2038d78a2cc92db740c99b1b8dc0101 (patch)
tree0bcbb02a1110495b7fb46eb4c8f3776a0849efaf /libpod/define/exec_codes.go
parent0d441f57d64bcca16c14ca44b7c8f35ab687ea3f (diff)
parent01a8483a59eed8bc706b5219b903704544b66c10 (diff)
downloadpodman-eae9a009b2038d78a2cc92db740c99b1b8dc0101.tar.gz
podman-eae9a009b2038d78a2cc92db740c99b1b8dc0101.tar.bz2
podman-eae9a009b2038d78a2cc92db740c99b1b8dc0101.zip
Merge pull request #3624 from haircommander/conmon-exec-with-remote-exec
Add remote exec
Diffstat (limited to 'libpod/define/exec_codes.go')
-rw-r--r--libpod/define/exec_codes.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/libpod/define/exec_codes.go b/libpod/define/exec_codes.go
new file mode 100644
index 000000000..7184f1e59
--- /dev/null
+++ b/libpod/define/exec_codes.go
@@ -0,0 +1,30 @@
+package define
+
+import (
+ "github.com/pkg/errors"
+)
+
+const (
+ // ExecErrorCodeGeneric is the default error code to return from an exec session if libpod failed
+ // prior to calling the runtime
+ ExecErrorCodeGeneric = 125
+ // ExecErrorCodeCannotInvoke is the error code to return when the runtime fails to invoke a command
+ // an example of this can be found by trying to execute a directory:
+ // `podman exec -l /etc`
+ ExecErrorCodeCannotInvoke = 126
+ // ExecErrorCodeNotFound is the error code to return when a command cannot be found
+ ExecErrorCodeNotFound = 127
+)
+
+// TranslateExecErrorToExitCode takes an error and checks whether it
+// has a predefined exit code associated. If so, it returns that, otherwise it returns
+// the exit code originally stated in libpod.Exec()
+func TranslateExecErrorToExitCode(originalEC int, err error) int {
+ if errors.Cause(err) == ErrOCIRuntimePermissionDenied {
+ return ExecErrorCodeCannotInvoke
+ }
+ if errors.Cause(err) == ErrOCIRuntimeNotFound {
+ return ExecErrorCodeNotFound
+ }
+ return originalEC
+}