ctr: move namespaces command

Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
This commit is contained in:
Jess Valarezo 2017-10-25 22:00:14 -04:00
parent 750fd89b38
commit fdb6859921
2 changed files with 24 additions and 23 deletions

View File

@ -1,4 +1,4 @@
package main package namespaces
import ( import (
"fmt" "fmt"
@ -14,22 +14,23 @@ import (
"github.com/urfave/cli" "github.com/urfave/cli"
) )
var namespacesCommand = cli.Command{ // Command is the cli command for managing namespaces
var Command = cli.Command{
Name: "namespaces", Name: "namespaces",
Usage: "manage namespaces", Usage: "manage namespaces",
Subcommands: cli.Commands{ Subcommands: cli.Commands{
namespacesCreateCommand, createCommand,
namespacesSetLabelsCommand, setLabelsCommand,
namespacesListCommand, listCommand,
namespacesRemoveCommand, removeCommand,
}, },
} }
var namespacesCreateCommand = cli.Command{ var createCommand = cli.Command{
Name: "create", Name: "create",
Usage: "create a new namespace.", Usage: "create a new namespace",
ArgsUsage: "[flags] <name> [<key>=<value]", ArgsUsage: "<name> [<key>=<value]",
Description: "Create a new namespace. It must be unique.", Description: "create a new namespace. it must be unique",
Action: func(context *cli.Context) error { Action: func(context *cli.Context) error {
namespace, labels := commands.ObjectWithLabelArgs(context) namespace, labels := commands.ObjectWithLabelArgs(context)
if namespace == "" { if namespace == "" {
@ -45,12 +46,11 @@ var namespacesCreateCommand = cli.Command{
}, },
} }
var namespacesSetLabelsCommand = cli.Command{ var setLabelsCommand = cli.Command{
Name: "label", Name: "label",
Usage: "set and clear labels for a namespace.", Usage: "set and clear labels for a namespace",
ArgsUsage: "[flags] <name> [<key>=<value>, ...]", ArgsUsage: "<name> [<key>=<value>, ...]",
Description: "Set and clear labels for a namespace.", Description: "set and clear labels for a namespace",
Flags: []cli.Flag{},
Action: func(context *cli.Context) error { Action: func(context *cli.Context) error {
namespace, labels := commands.ObjectWithLabelArgs(context) namespace, labels := commands.ObjectWithLabelArgs(context)
if namespace == "" { if namespace == "" {
@ -71,16 +71,16 @@ var namespacesSetLabelsCommand = cli.Command{
}, },
} }
var namespacesListCommand = cli.Command{ var listCommand = cli.Command{
Name: "list", Name: "list",
Aliases: []string{"ls"}, Aliases: []string{"ls"},
Usage: "list namespaces.", Usage: "list namespaces",
ArgsUsage: "[flags]", ArgsUsage: "[flags]",
Description: "List namespaces.", Description: "list namespaces",
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.BoolFlag{ cli.BoolFlag{
Name: "quiet, q", Name: "quiet, q",
Usage: "print only the namespace name.", Usage: "print only the namespace name",
}, },
}, },
Action: func(context *cli.Context) error { Action: func(context *cli.Context) error {
@ -123,12 +123,12 @@ var namespacesListCommand = cli.Command{
}, },
} }
var namespacesRemoveCommand = cli.Command{ var removeCommand = cli.Command{
Name: "remove", Name: "remove",
Aliases: []string{"rm"}, Aliases: []string{"rm"},
Usage: "remove one or more namespaces", Usage: "remove one or more namespaces",
ArgsUsage: "[flags] <name> [<name>, ...]", ArgsUsage: "<name> [<name>, ...]",
Description: "Remove one or more namespaces. For now, the namespace must be empty.", Description: "remove one or more namespaces. for now, the namespace must be empty",
Action: func(context *cli.Context) error { Action: func(context *cli.Context) error {
var exitErr error var exitErr error
client, ctx, cancel, err := commands.NewClient(context) client, ctx, cancel, err := commands.NewClient(context)

View File

@ -9,6 +9,7 @@ import (
"github.com/containerd/containerd/cmd/ctr/commands/containers" "github.com/containerd/containerd/cmd/ctr/commands/containers"
"github.com/containerd/containerd/cmd/ctr/commands/content" "github.com/containerd/containerd/cmd/ctr/commands/content"
"github.com/containerd/containerd/cmd/ctr/commands/images" "github.com/containerd/containerd/cmd/ctr/commands/images"
namespacesCmd "github.com/containerd/containerd/cmd/ctr/commands/namespaces"
"github.com/containerd/containerd/cmd/ctr/commands/plugins" "github.com/containerd/containerd/cmd/ctr/commands/plugins"
"github.com/containerd/containerd/cmd/ctr/commands/snapshot" "github.com/containerd/containerd/cmd/ctr/commands/snapshot"
versionCmd "github.com/containerd/containerd/cmd/ctr/commands/version" versionCmd "github.com/containerd/containerd/cmd/ctr/commands/version"
@ -79,7 +80,7 @@ containerd CLI
fetchCommand, fetchCommand,
fetchObjectCommand, fetchObjectCommand,
images.Command, images.Command,
namespacesCommand, namespacesCmd.Command,
pprofCommand, pprofCommand,
pullCommand, pullCommand,
pushCommand, pushCommand,