2017-01-27 19:00:29 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
contextpkg "context"
|
|
|
|
"os"
|
|
|
|
|
2017-04-03 20:14:15 +00:00
|
|
|
"github.com/containerd/containerd/archive"
|
|
|
|
"github.com/containerd/containerd/archive/compression"
|
|
|
|
"github.com/containerd/containerd/log"
|
2017-01-27 19:00:29 +00:00
|
|
|
"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
|
|
|
|
},
|
|
|
|
}
|