Only define a single process

This removes the Processes slice and only allows for one process of the
container.  It also renames TTY to Terminal for a cross platform
meaning.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2015-06-29 11:21:05 -07:00
parent cb44dec571
commit b2d9d99610
5 changed files with 40 additions and 45 deletions

View File

@ -43,10 +43,11 @@ user named `daemon` defined within that file-system.
```json
{
"version": "0.1",
"platform": {
"os": "linux",
"arch": "amd64",
"processes": [
{
"arch": "amd64"
},
"process": {
"tty": true,
"user": "daemon",
"args": [
@ -57,8 +58,7 @@ user named `daemon` defined within that file-system.
"TERM=xterm"
],
"cwd": ""
}
],
},
"root": {
"path": "rootfs",
"readonly": true

View File

@ -82,7 +82,7 @@ func restoreContainer(context *cli.Context, spec *Spec, config *configs.Config,
Stdout: os.Stdout,
Stderr: os.Stderr,
}
tty, err := newTty(spec.Processes[0].TTY, process, rootuid)
tty, err := newTty(spec.Process.Terminal, process, rootuid)
if err != nil {
return -1, err
}

7
run.go
View File

@ -10,9 +10,6 @@ import (
)
func execContainer(context *cli.Context, spec *Spec) (int, error) {
if len(spec.Processes) != 1 {
return -1, fmt.Errorf("runc only supports one(1) process for the container")
}
config, err := createLibcontainerConfig(spec)
if err != nil {
return -1, err
@ -38,8 +35,8 @@ func execContainer(context *cli.Context, spec *Spec) (int, error) {
// ensure that the container is always removed if we were the process
// that created it.
defer destroy(container)
process := newProcess(spec.Processes[0])
tty, err := newTty(spec.Processes[0].TTY, process, rootuid)
process := newProcess(spec.Process)
tty, err := newTty(spec.Process.Terminal, process, rootuid)
if err != nil {
return -1, err
}

10
spec.go
View File

@ -18,7 +18,7 @@ type Mount struct {
}
type Process struct {
TTY bool `json:"tty"`
Terminal bool `json:"tty"`
User string `json:"user"`
Args []string `json:"args"`
Env []string `json:"env"`
@ -43,7 +43,7 @@ type Platform struct {
type PortableSpec struct {
Version string `json:"version"`
Platform Platform `json:"platform"`
Processes []*Process `json:"processes"`
Process Process `json:"process"`
Root Root `json:"root"`
Hostname string `json:"hostname"`
Mounts []Mount `json:"mounts"`
@ -63,9 +63,8 @@ var specCommand = cli.Command{
Path: "rootfs",
Readonly: true,
},
Processes: []*Process{
{
TTY: true,
Process: Process{
Terminal: true,
User: "daemon",
Args: []string{
"sh",
@ -75,7 +74,6 @@ var specCommand = cli.Command{
"TERM=xterm",
},
},
},
Hostname: "shell",
Mounts: []Mount{
{

View File

@ -160,7 +160,7 @@ func getDefaultImagePath(context *cli.Context) string {
// newProcess returns a new libcontainer Process with the arguments from the
// spec and stdio from the current process.
func newProcess(p *Process) *libcontainer.Process {
func newProcess(p Process) *libcontainer.Process {
return &libcontainer.Process{
Args: p.Args,
Env: p.Env,