ctr: add ctr snapshot info <key>

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
This commit is contained in:
Akihiro Suda
2017-08-15 06:24:43 +00:00
parent 22df20b35f
commit fef7f3addc
4 changed files with 43 additions and 21 deletions

View File

@@ -27,6 +27,7 @@ var snapshotCommand = cli.Command{
treeSnapshotCommand,
mountSnapshotCommand,
commitSnapshotCommand,
infoSnapshotCommand,
},
}
@@ -312,6 +313,36 @@ var treeSnapshotCommand = cli.Command{
},
}
var infoSnapshotCommand = cli.Command{
Name: "info",
Usage: "get info about a snapshot",
ArgsUsage: "<key>",
Action: func(clicontext *cli.Context) error {
ctx, cancel := appContext(clicontext)
defer cancel()
if clicontext.NArg() != 1 {
return cli.ShowSubcommandHelp(clicontext)
}
key := clicontext.Args().Get(0)
snapshotter, err := getSnapshotter(clicontext)
if err != nil {
return err
}
info, err := snapshotter.Stat(ctx, key)
if err != nil {
return err
}
printAsJSON(info)
return nil
},
}
type snapshotTreeNode struct {
Name string
Parent string