mirror of
https://github.com/containers/podman
synced 2024-10-20 09:13:46 +00:00
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>
This commit is contained in:
parent
3d78085d52
commit
7377870641
|
@ -6,6 +6,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
@ -837,13 +838,35 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (err error) {
|
||||||
runtime.ociRuntimes[name] = ociRuntime
|
runtime.ociRuntimes[name] = ociRuntime
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set default runtime
|
// Do we have a default OCI runtime?
|
||||||
if runtime.config.OCIRuntime != "" {
|
if runtime.config.OCIRuntime != "" {
|
||||||
ociRuntime, ok := runtime.ociRuntimes[runtime.config.OCIRuntime]
|
// If the string starts with / it's a path to a runtime
|
||||||
if !ok {
|
// executable.
|
||||||
return errors.Wrapf(ErrInvalidArg, "default OCI runtime %q not found", runtime.config.OCIRuntime)
|
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?
|
// Do we have at least one valid OCI runtime?
|
||||||
|
|
Loading…
Reference in a new issue