2015-03-25 03:57:23 +00:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
flag "github.com/docker/docker/pkg/mflag"
|
|
|
|
)
|
|
|
|
|
2015-03-25 17:34:41 +00:00
|
|
|
// CmdLoad loads an image from a tar archive.
|
|
|
|
//
|
|
|
|
// The tar archive is read from STDIN by default, or from a tar archive file.
|
|
|
|
//
|
|
|
|
// Usage: docker load [OPTIONS]
|
2015-03-25 03:57:23 +00:00
|
|
|
func (cli *DockerCli) CmdLoad(args ...string) error {
|
2015-05-14 02:45:01 +00:00
|
|
|
cmd := cli.Subcmd("load", nil, "Load an image from a tar archive on STDIN", true)
|
2015-03-25 03:57:23 +00:00
|
|
|
infile := cmd.String([]string{"i", "-input"}, "", "Read from a tar archive file, instead of STDIN")
|
|
|
|
cmd.Require(flag.Exact, 0)
|
|
|
|
|
2015-03-29 01:22:46 +00:00
|
|
|
cmd.ParseFlags(args, true)
|
2015-03-25 03:57:23 +00:00
|
|
|
|
|
|
|
var (
|
|
|
|
input io.Reader = cli.in
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
if *infile != "" {
|
|
|
|
input, err = os.Open(*infile)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2015-05-01 18:23:44 +00:00
|
|
|
sopts := &streamOpts{
|
|
|
|
rawTerminal: true,
|
|
|
|
in: input,
|
|
|
|
out: cli.out,
|
|
|
|
}
|
|
|
|
if err := cli.stream("POST", "/images/load", sopts); err != nil {
|
2015-03-25 03:57:23 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|