From 38bf746466109391fc7d89ea8fb1532caf93d4af Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Fri, 2 Dec 2016 13:42:50 -0800 Subject: [PATCH] Add `ID` field for `docker plugin ls` This fix tries to address the enhancement proposed in 28708 to display ID field for the output of `docker plugin ls`. This fix add `ID` field to the output of `docker plugin ls` Related docs has been updated. This fix fixes 28708. Signed-off-by: Yong Tang Upstream-commit: 0449997cf6f1db858fc8274ab653bc49b6b3e835 Component: cli --- components/cli/command/plugin/list.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/cli/command/plugin/list.go b/components/cli/command/plugin/list.go index e402d44b31..4f800d7ec1 100644 --- a/components/cli/command/plugin/list.go +++ b/components/cli/command/plugin/list.go @@ -7,6 +7,7 @@ import ( "github.com/docker/docker/cli" "github.com/docker/docker/cli/command" + "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/stringutils" "github.com/spf13/cobra" "golang.org/x/net/context" @@ -43,17 +44,19 @@ func runList(dockerCli *command.DockerCli, opts listOptions) error { } w := tabwriter.NewWriter(dockerCli.Out(), 20, 1, 3, ' ', 0) - fmt.Fprintf(w, "NAME \tTAG \tDESCRIPTION\tENABLED") + fmt.Fprintf(w, "ID \tNAME \tTAG \tDESCRIPTION\tENABLED") fmt.Fprintf(w, "\n") for _, p := range plugins { + id := p.ID desc := strings.Replace(p.Config.Description, "\n", " ", -1) desc = strings.Replace(desc, "\r", " ", -1) if !opts.noTrunc { + id = stringid.TruncateID(p.ID) desc = stringutils.Ellipsis(desc, 45) } - fmt.Fprintf(w, "%s\t%s\t%s\t%v\n", p.Name, p.Tag, desc, p.Enabled) + fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%v\n", id, p.Name, p.Tag, desc, p.Enabled) } w.Flush() return nil