Fix bundle path for exec
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
ac43d4a0ab
commit
f23ff4d194
17
exec.go
17
exec.go
|
@ -6,7 +6,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
|
@ -79,19 +78,17 @@ func execProcess(context *cli.Context) (int, error) {
|
|||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
|
||||
var (
|
||||
detach = context.Bool("detach")
|
||||
rootfs = container.Config().Rootfs
|
||||
)
|
||||
|
||||
p, err := getProcess(context, path.Dir(rootfs))
|
||||
detach := context.Bool("detach")
|
||||
state, err := container.State()
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
bundle := searchLabels(state.Config.Labels, "bundle")
|
||||
p, err := getProcess(context, bundle)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
|
||||
return runProcess(container, p, nil, context.String("console"), context.String("pid-file"), detach)
|
||||
|
||||
}
|
||||
|
||||
func getProcess(context *cli.Context, bundle string) (*specs.Process, error) {
|
||||
|
|
8
list.go
8
list.go
|
@ -117,20 +117,20 @@ func getContainers(context *cli.Context) ([]containerState, error) {
|
|||
ID: state.BaseState.ID,
|
||||
InitProcessPid: state.BaseState.InitProcessPid,
|
||||
Status: containerStatus.String(),
|
||||
Bundle: getBundlePath(state.Config.Labels),
|
||||
Bundle: searchLabels(state.Config.Labels, "bundle"),
|
||||
Created: state.BaseState.Created})
|
||||
}
|
||||
}
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func getBundlePath(labels []string) string {
|
||||
func searchLabels(labels []string, query string) string {
|
||||
for _, l := range labels {
|
||||
parts := strings.SplitN(l, "=", 2)
|
||||
if len(parts) < 1 {
|
||||
if len(parts) < 2 {
|
||||
continue
|
||||
}
|
||||
if parts[0] == "bundle" {
|
||||
if parts[0] == query {
|
||||
return parts[1]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue