2017-01-27 19:00:29 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
contextpkg "context"
|
|
|
|
"os"
|
|
|
|
|
2017-02-08 01:01:43 +00:00
|
|
|
"github.com/docker/containerd/archive"
|
2017-02-21 06:00:09 +00:00
|
|
|
"github.com/docker/containerd/archive/compression"
|
2017-01-27 19:00:29 +00:00
|
|
|
"github.com/docker/containerd/log"
|
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
var applyCommand = cli.Command{
|
|
|
|
Name: "apply",
|
|
|
|
Usage: "apply layer from stdin to dir",
|
|
|
|
ArgsUsage: "[flags] <digest>",
|
|
|
|
Flags: []cli.Flag{},
|
|
|
|
Action: func(context *cli.Context) error {
|
|
|
|
var (
|
|
|
|
ctx = contextpkg.Background()
|
|
|
|
dir = context.Args().First()
|
|
|
|
)
|
|
|
|
|
|
|
|
log.G(ctx).Info("applying layer from stdin")
|
2017-02-08 01:01:43 +00:00
|
|
|
|
2017-02-21 06:00:09 +00:00
|
|
|
rd, err := compression.DecompressStream(os.Stdin)
|
2017-02-08 01:01:43 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-02-10 22:08:23 +00:00
|
|
|
if _, err := archive.Apply(ctx, dir, rd); err != nil {
|
2017-01-27 19:00:29 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|