Add linux runtime config
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
27a99400e8
commit
e1731d2e5e
1 changed files with 18 additions and 5 deletions
|
@ -22,23 +22,35 @@ import (
|
|||
const (
|
||||
runtimeName = "linux"
|
||||
configFilename = "config.json"
|
||||
defaultRuntime = "runc"
|
||||
)
|
||||
|
||||
func init() {
|
||||
plugin.Register(runtimeName, &plugin.Registration{
|
||||
Type: plugin.RuntimePlugin,
|
||||
Init: New,
|
||||
Type: plugin.RuntimePlugin,
|
||||
Init: New,
|
||||
Config: &Config{},
|
||||
})
|
||||
}
|
||||
|
||||
func New(ic *plugin.InitContext) (interface{}, error) {
|
||||
type Config struct {
|
||||
// Runtime is a path or name of an OCI runtime used by the shim
|
||||
Runtime string `toml:"runtime"`
|
||||
}
|
||||
|
||||
func New(ic *containerd.InitContext) (interface{}, error) {
|
||||
path := filepath.Join(ic.State, runtimeName)
|
||||
if err := os.MkdirAll(path, 0700); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cfg := ic.Config.(*Config)
|
||||
if cfg.Runtime == "" {
|
||||
cfg.Runtime = defaultRuntime
|
||||
}
|
||||
c, cancel := context.WithCancel(ic.Context)
|
||||
return &Runtime{
|
||||
root: path,
|
||||
runtime: cfg.Runtime,
|
||||
events: make(chan *containerd.Event, 2048),
|
||||
eventsContext: c,
|
||||
eventsCancel: cancel,
|
||||
|
@ -46,7 +58,8 @@ func New(ic *plugin.InitContext) (interface{}, error) {
|
|||
}
|
||||
|
||||
type Runtime struct {
|
||||
root string
|
||||
root string
|
||||
runtime string
|
||||
|
||||
events chan *containerd.Event
|
||||
eventsContext context.Context
|
||||
|
@ -70,7 +83,7 @@ func (r *Runtime) Create(ctx context.Context, id string, opts containerd.CreateO
|
|||
sopts := &shim.CreateRequest{
|
||||
ID: id,
|
||||
Bundle: path,
|
||||
Runtime: "runc",
|
||||
Runtime: r.runtime,
|
||||
Stdin: opts.IO.Stdin,
|
||||
Stdout: opts.IO.Stdout,
|
||||
Stderr: opts.IO.Stderr,
|
||||
|
|
Loading…
Reference in a new issue