mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
f37117045c
This patch introduces a new experimental engine-level plugin management with a new API and command line. Plugins can be distributed via a Docker registry, and their lifecycle is managed by the engine. This makes plugins a first-class construct. For more background, have a look at issue #20363. Documentation is in a separate commit. If you want to understand how the new plugin system works, you can start by reading the documentation. Note: backwards compatibility with existing plugins is maintained, albeit they won't benefit from the advantages of the new system. Signed-off-by: Tibor Vass <tibor@docker.com> Signed-off-by: Anusha Ragunathan <anusha@docker.com>
44 lines
895 B
Go
44 lines
895 B
Go
// +build experimental
|
|
|
|
package plugin
|
|
|
|
import (
|
|
"fmt"
|
|
"text/tabwriter"
|
|
|
|
"github.com/docker/docker/api/client"
|
|
"github.com/docker/docker/cli"
|
|
"github.com/spf13/cobra"
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
func newListCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "ls",
|
|
Short: "List plugins",
|
|
Aliases: []string{"list"},
|
|
Args: cli.ExactArgs(0),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
return runList(dockerCli)
|
|
},
|
|
}
|
|
|
|
return cmd
|
|
}
|
|
|
|
func runList(dockerCli *client.DockerCli) error {
|
|
plugins, err := dockerCli.Client().PluginList(context.Background())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
w := tabwriter.NewWriter(dockerCli.Out(), 20, 1, 3, ' ', 0)
|
|
fmt.Fprintf(w, "NAME \tTAG \tACTIVE")
|
|
fmt.Fprintf(w, "\n")
|
|
|
|
for _, p := range plugins {
|
|
fmt.Fprintf(w, "%s\t%s\t%v\n", p.Name, p.Tag, p.Active)
|
|
}
|
|
w.Flush()
|
|
return nil
|
|
}
|