Rename runc to oci package
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
49710435b7
commit
06e42ec370
2 changed files with 19 additions and 13 deletions
|
@ -8,8 +8,8 @@ import (
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/docker/containerkit"
|
"github.com/docker/containerkit"
|
||||||
|
"github.com/docker/containerkit/oci"
|
||||||
"github.com/docker/containerkit/osutils"
|
"github.com/docker/containerkit/osutils"
|
||||||
"github.com/docker/containerkit/runc"
|
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ func getContainerRootfs() containerkit.Mount {
|
||||||
|
|
||||||
func runContainer() error {
|
func runContainer() error {
|
||||||
// create a new runc runtime that implements the ExecutionDriver interface
|
// create a new runc runtime that implements the ExecutionDriver interface
|
||||||
driver, err := runc.New("/run/runc", "/tmp/runc")
|
driver, err := oci.New("/run/runc", "runc", "/tmp/runc")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package runc
|
package oci
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
@ -13,22 +13,28 @@ import (
|
||||||
"github.com/docker/containerkit"
|
"github.com/docker/containerkit"
|
||||||
)
|
)
|
||||||
|
|
||||||
func New(root, log string) (*Runc, error) {
|
func New(root, name, log string) (*OCIRuntime, error) {
|
||||||
if err := os.MkdirAll(root, 0711); err != nil {
|
if err := os.MkdirAll(root, 0711); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &Runc{
|
return &OCIRuntime{
|
||||||
root: root,
|
root: root,
|
||||||
log: log,
|
log: log,
|
||||||
|
name: name,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type Runc struct {
|
type OCIRuntime struct {
|
||||||
|
// root holds runtime state information for the containers
|
||||||
|
// launched by the runtime
|
||||||
root string
|
root string
|
||||||
|
// name is the name of the runtime, i.e. runc
|
||||||
|
name string
|
||||||
|
// log is the path to the log files for the containers
|
||||||
log string
|
log string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runc) Create(c *containerkit.Container) (containerkit.ProcessDelegate, error) {
|
func (r *OCIRuntime) Create(c *containerkit.Container) (containerkit.ProcessDelegate, error) {
|
||||||
pidFile := fmt.Sprintf("%s/%s.pid", filepath.Join(r.root, c.ID()), "init")
|
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())
|
cmd := r.command("create", "--pid-file", pidFile, "--bundle", c.Path(), c.ID())
|
||||||
cmd.Stdin, cmd.Stdout, cmd.Stderr = c.Stdin, c.Stdout, c.Stderr
|
cmd.Stdin, cmd.Stdout, cmd.Stderr = c.Stdin, c.Stdout, c.Stderr
|
||||||
|
@ -46,15 +52,15 @@ func (r *Runc) Create(c *containerkit.Container) (containerkit.ProcessDelegate,
|
||||||
return newProcess(i)
|
return newProcess(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runc) Start(c *containerkit.Container) error {
|
func (r *OCIRuntime) Start(c *containerkit.Container) error {
|
||||||
return r.command("start", c.ID()).Run()
|
return r.command("start", c.ID()).Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runc) Delete(c *containerkit.Container) error {
|
func (r *OCIRuntime) Delete(c *containerkit.Container) error {
|
||||||
return r.command("delete", c.ID()).Run()
|
return r.command("delete", c.ID()).Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runc) Exec(c *containerkit.Container, p *containerkit.Process) (containerkit.ProcessDelegate, error) {
|
func (r *OCIRuntime) Exec(c *containerkit.Container, p *containerkit.Process) (containerkit.ProcessDelegate, error) {
|
||||||
f, err := ioutil.TempFile(filepath.Join(r.root, c.ID()), "process")
|
f, err := ioutil.TempFile(filepath.Join(r.root, c.ID()), "process")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -82,8 +88,8 @@ func (r *Runc) Exec(c *containerkit.Container, p *containerkit.Process) (contain
|
||||||
return newProcess(i)
|
return newProcess(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runc) command(args ...string) *exec.Cmd {
|
func (r *OCIRuntime) command(args ...string) *exec.Cmd {
|
||||||
return exec.Command("runc", append([]string{
|
return exec.Command(r.name, append([]string{
|
||||||
"--root", r.root,
|
"--root", r.root,
|
||||||
"--log", r.log,
|
"--log", r.log,
|
||||||
}, args...)...)
|
}, args...)...)
|
Loading…
Reference in a new issue