Move plugins command
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
2dac1b6963
commit
ae995bc7b3
@ -1,4 +1,4 @@
|
|||||||
package main
|
package plugins
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -11,21 +11,22 @@ import (
|
|||||||
"github.com/containerd/containerd/api/types"
|
"github.com/containerd/containerd/api/types"
|
||||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||||
"github.com/containerd/containerd/platforms"
|
"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"
|
"github.com/urfave/cli"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
)
|
)
|
||||||
|
|
||||||
var pluginsCommand = cli.Command{
|
// Command is a cli command that outputs plugin information
|
||||||
|
var Command = cli.Command{
|
||||||
Name: "plugins",
|
Name: "plugins",
|
||||||
Usage: "Provides information about containerd plugins",
|
Usage: "provides information about containerd plugins",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "quiet, q",
|
Name: "quiet,q",
|
||||||
Usage: "print only the plugin ids",
|
Usage: "print only the plugin ids",
|
||||||
},
|
},
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "detailed, d",
|
Name: "detailed,d",
|
||||||
Usage: "print detailed information about each plugin",
|
Usage: "print detailed information about each plugin",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -52,7 +53,6 @@ var pluginsCommand = cli.Command{
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
w := tabwriter.NewWriter(os.Stdout, 4, 8, 4, ' ', 0)
|
w := tabwriter.NewWriter(os.Stdout, 4, 8, 4, ' ', 0)
|
||||||
if detailed {
|
if detailed {
|
||||||
first := true
|
first := true
|
||||||
@ -105,7 +105,6 @@ var pluginsCommand = cli.Command{
|
|||||||
if len(plugin.Platforms) > 0 {
|
if len(plugin.Platforms) > 0 {
|
||||||
platformColumn = prettyPlatforms(plugin.Platforms)
|
platformColumn = prettyPlatforms(plugin.Platforms)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t\n",
|
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t\n",
|
||||||
plugin.Type,
|
plugin.Type,
|
||||||
plugin.ID,
|
plugin.ID,
|
||||||
@ -122,7 +121,7 @@ var pluginsCommand = cli.Command{
|
|||||||
func prettyPlatforms(pspb []types.Platform) string {
|
func prettyPlatforms(pspb []types.Platform) string {
|
||||||
psm := map[string]struct{}{}
|
psm := map[string]struct{}{}
|
||||||
for _, p := range pspb {
|
for _, p := range pspb {
|
||||||
psm[platforms.Format(ocispec.Platform{
|
psm[platforms.Format(v1.Platform{
|
||||||
OS: p.OS,
|
OS: p.OS,
|
||||||
Architecture: p.Architecture,
|
Architecture: p.Architecture,
|
||||||
Variant: p.Variant,
|
Variant: p.Variant,
|
||||||
@ -133,6 +132,5 @@ func prettyPlatforms(pspb []types.Platform) string {
|
|||||||
ps = append(ps, p)
|
ps = append(ps, p)
|
||||||
}
|
}
|
||||||
sort.Stable(sort.StringSlice(ps))
|
sort.Stable(sort.StringSlice(ps))
|
||||||
|
|
||||||
return strings.Join(ps, ",")
|
return strings.Join(ps, ",")
|
||||||
}
|
}
|
@ -5,7 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||||
"github.com/google/cadvisor/version"
|
"github.com/containerd/containerd/version"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/containerd/containerd/cmd/ctr/commands/plugins"
|
||||||
versionCmd "github.com/containerd/containerd/cmd/ctr/commands/version"
|
versionCmd "github.com/containerd/containerd/cmd/ctr/commands/version"
|
||||||
"github.com/containerd/containerd/namespaces"
|
"github.com/containerd/containerd/namespaces"
|
||||||
"github.com/containerd/containerd/server"
|
"github.com/containerd/containerd/server"
|
||||||
@ -65,6 +66,8 @@ containerd CLI
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
app.Commands = append([]cli.Command{
|
app.Commands = append([]cli.Command{
|
||||||
|
plugins.Command,
|
||||||
|
versionCmd.Command,
|
||||||
applyCommand,
|
applyCommand,
|
||||||
containersCommand,
|
containersCommand,
|
||||||
contentCommand,
|
contentCommand,
|
||||||
@ -81,8 +84,6 @@ containerd CLI
|
|||||||
runCommand,
|
runCommand,
|
||||||
snapshotCommand,
|
snapshotCommand,
|
||||||
tasksCommand,
|
tasksCommand,
|
||||||
pluginsCommand,
|
|
||||||
versionCmd.Command,
|
|
||||||
}, extraCmds...)
|
}, extraCmds...)
|
||||||
app.Before = func(context *cli.Context) error {
|
app.Before = func(context *cli.Context) error {
|
||||||
if context.GlobalBool("debug") {
|
if context.GlobalBool("debug") {
|
||||||
|
Loading…
Reference in New Issue
Block a user