From f23ff4d1948780ffb8ea070bb6c78b587e94e6b4 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Wed, 24 Feb 2016 11:19:30 -0800 Subject: [PATCH] Fix bundle path for exec Signed-off-by: Michael Crosby --- exec.go | 17 +++++++---------- list.go | 8 ++++---- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/exec.go b/exec.go index a1da41889..528d3ade1 100644 --- a/exec.go +++ b/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) { diff --git a/list.go b/list.go index 643e8c1b7..50566f85b 100644 --- a/list.go +++ b/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] } }