1- package main
1+ package plugins
22
33import (
44 "fmt"
@@ -9,22 +9,24 @@ import (
99
1010 introspection "github.com/containerd/containerd/api/services/introspection/v1"
1111 "github.com/containerd/containerd/api/types"
12+ "github.com/containerd/containerd/cmd/ctr/commands"
1213 "github.com/containerd/containerd/platforms"
13- ocispec "github.com/opencontainers/image-spec/specs-go/v1"
14+ "github.com/opencontainers/image-spec/specs-go/v1"
1415 "github.com/urfave/cli"
1516 "google.golang.org/grpc/codes"
1617)
1718
18- var pluginsCommand = cli.Command {
19+ // Command is a cli command that outputs plugin information
20+ var Command = cli.Command {
1921 Name : "plugins" ,
20- Usage : "Provides information about containerd plugins" ,
22+ Usage : "provides information about containerd plugins" ,
2123 Flags : []cli.Flag {
2224 cli.BoolFlag {
23- Name : "quiet, q" ,
25+ Name : "quiet,q" ,
2426 Usage : "print only the plugin ids" ,
2527 },
2628 cli.BoolFlag {
27- Name : "detailed, d" ,
29+ Name : "detailed,d" ,
2830 Usage : "print detailed information about each plugin" ,
2931 },
3032 },
@@ -33,7 +35,7 @@ var pluginsCommand = cli.Command{
3335 quiet = context .Bool ("quiet" )
3436 detailed = context .Bool ("detailed" )
3537 )
36- client , ctx , cancel , err := newClient (context )
38+ client , ctx , cancel , err := commands . NewClient (context )
3739 if err != nil {
3840 return err
3941 }
@@ -51,7 +53,6 @@ var pluginsCommand = cli.Command{
5153 }
5254 return nil
5355 }
54-
5556 w := tabwriter .NewWriter (os .Stdout , 4 , 8 , 4 , ' ' , 0 )
5657 if detailed {
5758 first := true
@@ -104,7 +105,6 @@ var pluginsCommand = cli.Command{
104105 if len (plugin .Platforms ) > 0 {
105106 platformColumn = prettyPlatforms (plugin .Platforms )
106107 }
107-
108108 if _ , err := fmt .Fprintf (w , "%s\t %s\t %s\t %s\t \n " ,
109109 plugin .Type ,
110110 plugin .ID ,
@@ -121,7 +121,7 @@ var pluginsCommand = cli.Command{
121121func prettyPlatforms (pspb []types.Platform ) string {
122122 psm := map [string ]struct {}{}
123123 for _ , p := range pspb {
124- psm [platforms .Format (ocispec .Platform {
124+ psm [platforms .Format (v1 .Platform {
125125 OS : p .OS ,
126126 Architecture : p .Architecture ,
127127 Variant : p .Variant ,
@@ -132,6 +132,5 @@ func prettyPlatforms(pspb []types.Platform) string {
132132 ps = append (ps , p )
133133 }
134134 sort .Stable (sort .StringSlice (ps ))
135-
136135 return strings .Join (ps , "," )
137136}
0 commit comments