support using multiple snapshotters simultaneously

e.g. dist pull --snapshotter btrfs ...; ctr run --snapshotter btrfs ...
(empty string defaults for overlayfs)

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Akihiro Suda
2017-07-11 09:10:57 +00:00
committed by Michael Crosby
parent 8f1c11d862
commit b06aab713a
22 changed files with 743 additions and 255 deletions

7
cmd/dist/common.go vendored
View File

@@ -44,6 +44,13 @@ var registryFlags = []cli.Flag{
},
}
var snapshotterFlags = []cli.Flag{
cli.StringFlag{
Name: "snapshotter",
Usage: "Snapshotter name. Empty value stands for the daemon default value.",
},
}
func getClient(context *cli.Context) (*containerd.Client, error) {
address := context.GlobalString("address")
//timeout := context.GlobalDuration("connect-timeout")

4
cmd/dist/pull.go vendored
View File

@@ -20,7 +20,7 @@ command. As part of this process, we do the following:
2. Prepare the snapshot filesystem with the pulled resources.
3. Register metadata for the image.
`,
Flags: registryFlags,
Flags: append(registryFlags, snapshotterFlags...),
Action: func(clicontext *cli.Context) error {
var (
ref = clicontext.Args().First()
@@ -38,7 +38,7 @@ command. As part of this process, we do the following:
// TODO: Show unpack status
fmt.Printf("unpacking %s...", img.Target().Digest)
err = img.Unpack(ctx)
err = img.Unpack(ctx, clicontext.String("snapshotter"))
fmt.Println("done")
return err
},

4
cmd/dist/rootfs.go vendored
View File

@@ -21,7 +21,7 @@ var rootfsUnpackCommand = cli.Command{
Name: "unpack",
Usage: "unpack applies layers from a manifest to a snapshot",
ArgsUsage: "[flags] <digest>",
Flags: []cli.Flag{},
Flags: snapshotterFlags,
Action: func(clicontext *cli.Context) error {
ctx, cancel := appContext(clicontext)
defer cancel()
@@ -49,7 +49,7 @@ var rootfsUnpackCommand = cli.Command{
for _, image := range images {
if image.Target().Digest == dgst {
fmt.Printf("unpacking %s (%s)...", dgst, image.Target().MediaType)
if err := image.Unpack(ctx); err != nil {
if err := image.Unpack(ctx, clicontext.String("snapshotter")); err != nil {
fmt.Println()
return err
}