summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-06-20 15:05:46 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-06-20 15:07:46 -0400
commit7377870641c0d2a3ee705970369fe42fcf8aa88d (patch)
tree8d33dd96ca75e7c37377e55bf64a1c99dabb23ea
parent3d78085d52f3e809381eeb885794ced7e9db1352 (diff)
downloadpodman-7377870641c0d2a3ee705970369fe42fcf8aa88d.tar.gz
podman-7377870641c0d2a3ee705970369fe42fcf8aa88d.tar.bz2
podman-7377870641c0d2a3ee705970369fe42fcf8aa88d.zip
Properly handle OCI runtime being set to a path
This is done by the --runtime flag, and as such, by all our CI. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
-rw-r--r--libpod/runtime.go33
1 files changed, 28 insertions, 5 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go
index 56ad1ffe8..d4d34242c 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -6,6 +6,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
+ "strings"
"sync"
"syscall"
@@ -837,13 +838,35 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (err error) {
runtime.ociRuntimes[name] = ociRuntime
}
- // Set default runtime
+ // Do we have a default OCI runtime?
if runtime.config.OCIRuntime != "" {
- ociRuntime, ok := runtime.ociRuntimes[runtime.config.OCIRuntime]
- if !ok {
- return errors.Wrapf(ErrInvalidArg, "default OCI runtime %q not found", runtime.config.OCIRuntime)
+ // If the string starts with / it's a path to a runtime
+ // executable.
+ if strings.HasPrefix(runtime.config.OCIRuntime, "/") {
+ name := filepath.Base(runtime.config.OCIRuntime)
+
+ supportsJSON := false
+ for _, r := range runtime.config.RuntimeSupportsJSON {
+ if r == name {
+ supportsJSON = true
+ break
+ }
+ }
+
+ ociRuntime, err := newOCIRuntime(name, []string{runtime.config.OCIRuntime}, runtime.conmonPath, runtime.config, supportsJSON)
+ if err != nil {
+ return err
+ }
+
+ runtime.ociRuntimes[name] = ociRuntime
+ runtime.defaultOCIRuntime = ociRuntime
+ } else {
+ ociRuntime, ok := runtime.ociRuntimes[runtime.config.OCIRuntime]
+ if !ok {
+ return errors.Wrapf(ErrInvalidArg, "default OCI runtime %q not found", runtime.config.OCIRuntime)
+ }
+ runtime.defaultOCIRuntime = ociRuntime
}
- runtime.defaultOCIRuntime = ociRuntime
}
// Do we have at least one valid OCI runtime?