Finish port of shim package

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2016-10-05 15:07:20 -07:00
parent 0f33efb1f7
commit c76f883ccd
5 changed files with 424 additions and 90 deletions

View file

@ -2,6 +2,7 @@ package oci
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
@ -13,6 +14,8 @@ import (
"github.com/docker/containerkit"
)
var ErrRootEmpty = errors.New("oci: runtime root cannot be an empty string")
type Opts struct {
Name string
Root string
@ -20,6 +23,9 @@ type Opts struct {
}
func New(opts Opts) (*OCIRuntime, error) {
if opts.Root == "" {
return nil, ErrRootEmpty
}
if err := os.MkdirAll(opts.Root, 0711); err != nil {
return nil, err
}
@ -44,6 +50,10 @@ func (r *OCIRuntime) Name() string {
return r.name
}
func (r *OCIRuntime) Args() []string {
return r.args
}
func (r *OCIRuntime) Create(c *containerkit.Container) (containerkit.ProcessDelegate, error) {
pidFile := fmt.Sprintf("%s/%s.pid", filepath.Join(r.root, c.ID()), "init")
cmd := r.Command("create", "--pid-file", pidFile, "--bundle", c.Path(), c.ID())