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/docker/containerkit"
|
||||
"github.com/docker/containerkit/oci"
|
||||
"github.com/docker/containerkit/osutils"
|
||||
"github.com/docker/containerkit/runc"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
)
|
||||
|
||||
|
@ -29,7 +29,7 @@ func getContainerRootfs() containerkit.Mount {
|
|||
|
||||
func runContainer() error {
|
||||
// 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 {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package runc
|
||||
package oci
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
@ -13,22 +13,28 @@ import (
|
|||
"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 {
|
||||
return nil, err
|
||||
}
|
||||
return &Runc{
|
||||
return &OCIRuntime{
|
||||
root: root,
|
||||
log: log,
|
||||
name: name,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type Runc struct {
|
||||
type OCIRuntime struct {
|
||||
// root holds runtime state information for the containers
|
||||
// launched by the runtime
|
||||
root string
|
||||
log 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
|
||||
}
|
||||
|
||||
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")
|
||||
cmd := r.command("create", "--pid-file", pidFile, "--bundle", c.Path(), c.ID())
|
||||
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)
|
||||
}
|
||||
|
||||
func (r *Runc) Start(c *containerkit.Container) error {
|
||||
func (r *OCIRuntime) Start(c *containerkit.Container) error {
|
||||
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()
|
||||
}
|
||||
|
||||
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")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -82,8 +88,8 @@ func (r *Runc) Exec(c *containerkit.Container, p *containerkit.Process) (contain
|
|||
return newProcess(i)
|
||||
}
|
||||
|
||||
func (r *Runc) command(args ...string) *exec.Cmd {
|
||||
return exec.Command("runc", append([]string{
|
||||
func (r *OCIRuntime) command(args ...string) *exec.Cmd {
|
||||
return exec.Command(r.name, append([]string{
|
||||
"--root", r.root,
|
||||
"--log", r.log,
|
||||
}, args...)...)
|
Loading…
Reference in a new issue