From f7306d7f6c98bd2abdc66464cd8960f1528f15af Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Fri, 14 Jul 2017 14:50:02 -0700 Subject: [PATCH] cmd/{ctr,dist}: move images command to ctr Rather than make a large PR, we can move parts of the dist commands over piece by piece. This first step moves over the images command. Others will follow. Signed-off-by: Stephen J Day --- cmd/{dist => ctr}/images.go | 33 +++------------------------------ cmd/ctr/main.go | 9 +++++++-- cmd/dist/labels.go | 27 ++++++++++++++++++++++++++- cmd/dist/main.go | 14 +------------- 4 files changed, 37 insertions(+), 46 deletions(-) rename cmd/{dist => ctr}/images.go (83%) diff --git a/cmd/dist/images.go b/cmd/ctr/images.go similarity index 83% rename from cmd/dist/images.go rename to cmd/ctr/images.go index 21a2c3631..c047834af 100644 --- a/cmd/dist/images.go +++ b/cmd/ctr/images.go @@ -39,7 +39,7 @@ var imagesListCommand = cli.Command{ ) defer cancel() - client, err := getClient(clicontext) + client, err := newClient(clicontext) if err != nil { return err } @@ -95,7 +95,7 @@ var imagesSetLabelsCommand = cli.Command{ ) defer cancel() - client, err := getClient(clicontext) + client, err := newClient(clicontext) if err != nil { return err } @@ -148,7 +148,7 @@ var imageRemoveCommand = cli.Command{ ctx, cancel := appContext(clicontext) defer cancel() - client, err := getClient(clicontext) + client, err := newClient(clicontext) if err != nil { return err } @@ -172,30 +172,3 @@ var imageRemoveCommand = cli.Command{ return exitErr }, } - -// TODO(stevvooe): These helpers should go away when we merge dist and ctr. - -func objectWithLabelArgs(clicontext *cli.Context) (string, map[string]string) { - var ( - name = clicontext.Args().First() - labelStrings = clicontext.Args().Tail() - ) - - return name, labelArgs(labelStrings) -} - -func labelArgs(labelStrings []string) map[string]string { - 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 labels -} diff --git a/cmd/ctr/main.go b/cmd/ctr/main.go index 0ae139fce..8427dc553 100644 --- a/cmd/ctr/main.go +++ b/cmd/ctr/main.go @@ -46,6 +46,10 @@ containerd CLI Name: "timeout", Usage: "total timeout for ctr commands", }, + cli.DurationFlag{ + Name: "connect-timeout", + Usage: "timeout for connecting to containerd", + }, cli.StringFlag{ Name: "namespace, n", Usage: "namespace to use with commands", @@ -54,13 +58,14 @@ containerd CLI }, } app.Commands = append([]cli.Command{ - attachCommand, + imageCommand, + containersCommand, checkpointCommand, runCommand, + attachCommand, deleteCommand, namespacesCommand, eventsCommand, - containersCommand, taskListCommand, infoCommand, killCommand, diff --git a/cmd/dist/labels.go b/cmd/dist/labels.go index 4e1b17e33..b0ddd8350 100644 --- a/cmd/dist/labels.go +++ b/cmd/dist/labels.go @@ -9,7 +9,7 @@ import ( "github.com/urfave/cli" ) -var labelCommand = cli.Command{ +var labelContentCommand = cli.Command{ Name: "label", Usage: "adds labels to content", ArgsUsage: "[flags] [