ctr: move snapshot command

Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
This commit is contained in:
Jess Valarezo 2017-10-25 21:23:41 -04:00
parent 0895dbe932
commit 750fd89b38
2 changed files with 30 additions and 29 deletions

View File

@ -1,4 +1,4 @@
package main package snapshot
import ( import (
gocontext "context" gocontext "context"
@ -15,25 +15,26 @@ import (
"github.com/urfave/cli" "github.com/urfave/cli"
) )
var snapshotCommand = cli.Command{ // Command is the cli command for managing snapshots
var Command = cli.Command{
Name: "snapshot", Name: "snapshot",
Usage: "snapshot management", Usage: "manage snapshots",
Flags: commands.SnapshotterFlags, Flags: commands.SnapshotterFlags,
Subcommands: cli.Commands{ Subcommands: cli.Commands{
listSnapshotCommand, listCommand,
usageSnapshotCommand, usageCommand,
removeSnapshotCommand, removeCommand,
prepareSnapshotCommand, prepareCommand,
viewSnapshotCommand, viewCommand,
treeSnapshotCommand, treeCommand,
mountSnapshotCommand, mountCommand,
commitSnapshotCommand, commitCommand,
infoSnapshotCommand, infoCommand,
labelSnapshotCommand, setLabelCommand,
}, },
} }
var listSnapshotCommand = cli.Command{ var listCommand = cli.Command{
Name: "list", Name: "list",
Aliases: []string{"ls"}, Aliases: []string{"ls"},
Usage: "list snapshots", Usage: "list snapshots",
@ -62,7 +63,7 @@ var listSnapshotCommand = cli.Command{
}, },
} }
var usageSnapshotCommand = cli.Command{ var usageCommand = cli.Command{
Name: "usage", Name: "usage",
Usage: "usage snapshots", Usage: "usage snapshots",
ArgsUsage: "[flags] [<key>, ...]", ArgsUsage: "[flags] [<key>, ...]",
@ -118,7 +119,7 @@ var usageSnapshotCommand = cli.Command{
}, },
} }
var removeSnapshotCommand = cli.Command{ var removeCommand = cli.Command{
Name: "remove", Name: "remove",
Aliases: []string{"rm"}, Aliases: []string{"rm"},
ArgsUsage: "<key> [<key>, ...]", ArgsUsage: "<key> [<key>, ...]",
@ -141,7 +142,7 @@ var removeSnapshotCommand = cli.Command{
}, },
} }
var prepareSnapshotCommand = cli.Command{ var prepareCommand = cli.Command{
Name: "prepare", Name: "prepare",
Usage: "prepare a snapshot from a committed snapshot", Usage: "prepare a snapshot from a committed snapshot",
ArgsUsage: "[flags] <key> [<parent>]", ArgsUsage: "[flags] <key> [<parent>]",
@ -180,7 +181,7 @@ var prepareSnapshotCommand = cli.Command{
}, },
} }
var viewSnapshotCommand = cli.Command{ var viewCommand = cli.Command{
Name: "view", Name: "view",
Usage: "create a read-only snapshot from a committed snapshot", Usage: "create a read-only snapshot from a committed snapshot",
ArgsUsage: "[flags] <key> [<parent>]", ArgsUsage: "[flags] <key> [<parent>]",
@ -219,11 +220,11 @@ var viewSnapshotCommand = cli.Command{
}, },
} }
var mountSnapshotCommand = cli.Command{ var mountCommand = cli.Command{
Name: "mounts", Name: "mounts",
Aliases: []string{"m", "mount"}, Aliases: []string{"m", "mount"},
Usage: "mount gets mount commands for the snapshots", Usage: "mount gets mount commands for the snapshots",
ArgsUsage: "[flags] <target> <key>", ArgsUsage: "<target> <key>",
Action: func(context *cli.Context) error { Action: func(context *cli.Context) error {
if context.NArg() != 2 { if context.NArg() != 2 {
return cli.ShowSubcommandHelp(context) return cli.ShowSubcommandHelp(context)
@ -249,10 +250,10 @@ var mountSnapshotCommand = cli.Command{
}, },
} }
var commitSnapshotCommand = cli.Command{ var commitCommand = cli.Command{
Name: "commit", Name: "commit",
Usage: "commit an active snapshot into the provided name", Usage: "commit an active snapshot into the provided name",
ArgsUsage: "[flags] <key> <active>", ArgsUsage: "<key> <active>",
Action: func(context *cli.Context) error { Action: func(context *cli.Context) error {
if context.NArg() != 2 { if context.NArg() != 2 {
return cli.ShowSubcommandHelp(context) return cli.ShowSubcommandHelp(context)
@ -271,7 +272,7 @@ var commitSnapshotCommand = cli.Command{
}, },
} }
var treeSnapshotCommand = cli.Command{ var treeCommand = cli.Command{
Name: "tree", Name: "tree",
Usage: "display tree view of snapshot branches", Usage: "display tree view of snapshot branches",
Action: func(context *cli.Context) error { Action: func(context *cli.Context) error {
@ -305,7 +306,7 @@ var treeSnapshotCommand = cli.Command{
}, },
} }
var infoSnapshotCommand = cli.Command{ var infoCommand = cli.Command{
Name: "info", Name: "info",
Usage: "get info about a snapshot", Usage: "get info about a snapshot",
ArgsUsage: "<key>", ArgsUsage: "<key>",
@ -332,12 +333,11 @@ var infoSnapshotCommand = cli.Command{
}, },
} }
var labelSnapshotCommand = cli.Command{ var setLabelCommand = cli.Command{
Name: "label", Name: "label",
Usage: "add labels to content", Usage: "add labels to content",
ArgsUsage: "[flags] <name> [<label>=<value> ...]", ArgsUsage: "<name> [<label>=<value> ...]",
Description: `Labels snapshots in the snapshotter`, Description: "labels snapshots in the snapshotter",
Flags: []cli.Flag{},
Action: func(context *cli.Context) error { Action: func(context *cli.Context) error {
key, labels := commands.ObjectWithLabelArgs(context) key, labels := commands.ObjectWithLabelArgs(context)
client, ctx, cancel, err := commands.NewClient(context) client, ctx, cancel, err := commands.NewClient(context)

View File

@ -10,6 +10,7 @@ import (
"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"
"github.com/containerd/containerd/cmd/ctr/commands/plugins" "github.com/containerd/containerd/cmd/ctr/commands/plugins"
"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"
"github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/server" "github.com/containerd/containerd/server"
@ -85,7 +86,7 @@ containerd CLI
pushObjectCommand, pushObjectCommand,
rootfsCommand, rootfsCommand,
runCommand, runCommand,
snapshotCommand, snapshot.Command,
tasksCommand, tasksCommand,
}, extraCmds...) }, extraCmds...)
app.Before = func(context *cli.Context) error { app.Before = func(context *cli.Context) error {