Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions cli/command/image/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ func NewLoadCommand(dockerCli command.Cli) *cobra.Command {

func runLoad(ctx context.Context, dockerCli command.Cli, opts loadOptions) error {
var input io.Reader = dockerCli.In()
if opts.input != "" {

// TODO(thaJeztah): add support for "-" as STDIN to match other commands, possibly making it a required positional argument.
switch opts.input {
case "":
// To avoid getting stuck, verify that a tar file is given either in
// the input flag or through stdin and if not display an error message and exit.
if dockerCli.In().IsTerminal() {
return errors.Errorf("requested load from stdin, but stdin is empty")
}
default:
// We use sequential.Open to use sequential file access on Windows, avoiding
// depleting the standby list un-necessarily. On Linux, this equates to a regular os.Open.
file, err := sequential.Open(opts.input)
Expand All @@ -62,12 +71,6 @@ func runLoad(ctx context.Context, dockerCli command.Cli, opts loadOptions) error
input = file
}

// To avoid getting stuck, verify that a tar file is given either in
// the input flag or through stdin and if not display an error message and exit.
if opts.input == "" && dockerCli.In().IsTerminal() {
return errors.Errorf("requested load from stdin, but stdin is empty")
}

var options []client.ImageLoadOption
if opts.quiet || !dockerCli.Out().IsTerminal() {
options = append(options, client.ImageLoadWithQuiet(true))
Expand Down