cmd/ctr, service/containers: implement container filter

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day
2017-06-21 15:29:58 -07:00
parent 3332042ab6
commit 396d89e423
16 changed files with 409 additions and 189 deletions

View File

@@ -33,7 +33,7 @@ var namespacesCreateCommand = cli.Command{
Action: func(clicontext *cli.Context) error {
var (
ctx = context.Background()
namespace, labels = namespaceWithLabelArgs(clicontext)
namespace, labels = objectWithLabelArgs(clicontext)
)
if namespace == "" {
@@ -53,27 +53,6 @@ var namespacesCreateCommand = cli.Command{
},
}
func namespaceWithLabelArgs(clicontext *cli.Context) (string, map[string]string) {
var (
namespace = clicontext.Args().First()
labelStrings = clicontext.Args().Tail()
labels = make(map[string]string, len(labelStrings))
)
for _, label := range labelStrings {
parts := strings.SplitN(label, "=", 2)
key := parts[0]
value := "true"
if len(parts) > 1 {
value = parts[1]
}
labels[key] = value
}
return namespace, labels
}
var namespacesSetLabelsCommand = cli.Command{
Name: "set-labels",
Usage: "Set and clear labels for a namespace.",
@@ -83,7 +62,7 @@ var namespacesSetLabelsCommand = cli.Command{
Action: func(clicontext *cli.Context) error {
var (
ctx = context.Background()
namespace, labels = namespaceWithLabelArgs(clicontext)
namespace, labels = objectWithLabelArgs(clicontext)
)
namespaces, err := getNamespacesService(clicontext)