From ae995bc7b370b5867dc9286034da4f943760a1f8 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Wed, 25 Oct 2017 11:16:34 -0400 Subject: [PATCH] Move plugins command Signed-off-by: Michael Crosby --- cmd/ctr/{ => commands/plugins}/plugins.go | 18 ++++++++---------- cmd/ctr/commands/version/version.go | 2 +- cmd/ctr/main.go | 5 +++-- 3 files changed, 12 insertions(+), 13 deletions(-) rename cmd/ctr/{ => commands/plugins}/plugins.go (90%) diff --git a/cmd/ctr/plugins.go b/cmd/ctr/commands/plugins/plugins.go similarity index 90% rename from cmd/ctr/plugins.go rename to cmd/ctr/commands/plugins/plugins.go index 9c987f799..0fa6eeae6 100644 --- a/cmd/ctr/plugins.go +++ b/cmd/ctr/commands/plugins/plugins.go @@ -1,4 +1,4 @@ -package main +package plugins import ( "fmt" @@ -11,21 +11,22 @@ import ( "github.com/containerd/containerd/api/types" "github.com/containerd/containerd/cmd/ctr/commands" "github.com/containerd/containerd/platforms" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/opencontainers/image-spec/specs-go/v1" "github.com/urfave/cli" "google.golang.org/grpc/codes" ) -var pluginsCommand = cli.Command{ +// Command is a cli command that outputs plugin information +var Command = cli.Command{ Name: "plugins", - Usage: "Provides information about containerd plugins", + Usage: "provides information about containerd plugins", Flags: []cli.Flag{ cli.BoolFlag{ - Name: "quiet, q", + Name: "quiet,q", Usage: "print only the plugin ids", }, cli.BoolFlag{ - Name: "detailed, d", + Name: "detailed,d", Usage: "print detailed information about each plugin", }, }, @@ -52,7 +53,6 @@ var pluginsCommand = cli.Command{ } return nil } - w := tabwriter.NewWriter(os.Stdout, 4, 8, 4, ' ', 0) if detailed { first := true @@ -105,7 +105,6 @@ var pluginsCommand = cli.Command{ if len(plugin.Platforms) > 0 { platformColumn = prettyPlatforms(plugin.Platforms) } - if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t\n", plugin.Type, plugin.ID, @@ -122,7 +121,7 @@ var pluginsCommand = cli.Command{ func prettyPlatforms(pspb []types.Platform) string { psm := map[string]struct{}{} for _, p := range pspb { - psm[platforms.Format(ocispec.Platform{ + psm[platforms.Format(v1.Platform{ OS: p.OS, Architecture: p.Architecture, Variant: p.Variant, @@ -133,6 +132,5 @@ func prettyPlatforms(pspb []types.Platform) string { ps = append(ps, p) } sort.Stable(sort.StringSlice(ps)) - return strings.Join(ps, ",") } diff --git a/cmd/ctr/commands/version/version.go b/cmd/ctr/commands/version/version.go index 4058d862d..37dd52e02 100644 --- a/cmd/ctr/commands/version/version.go +++ b/cmd/ctr/commands/version/version.go @@ -5,7 +5,7 @@ import ( "os" "github.com/containerd/containerd/cmd/ctr/commands" - "github.com/google/cadvisor/version" + "github.com/containerd/containerd/version" "github.com/urfave/cli" ) diff --git a/cmd/ctr/main.go b/cmd/ctr/main.go index e486b119f..b96f1e92e 100644 --- a/cmd/ctr/main.go +++ b/cmd/ctr/main.go @@ -6,6 +6,7 @@ import ( "log" "os" + "github.com/containerd/containerd/cmd/ctr/commands/plugins" versionCmd "github.com/containerd/containerd/cmd/ctr/commands/version" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/server" @@ -65,6 +66,8 @@ containerd CLI }, } app.Commands = append([]cli.Command{ + plugins.Command, + versionCmd.Command, applyCommand, containersCommand, contentCommand, @@ -81,8 +84,6 @@ containerd CLI runCommand, snapshotCommand, tasksCommand, - pluginsCommand, - versionCmd.Command, }, extraCmds...) app.Before = func(context *cli.Context) error { if context.GlobalBool("debug") {