@@ -51,7 +51,16 @@ func NewLoadCommand(dockerCli command.Cli) *cobra.Command {
51
51
52
52
func runLoad (ctx context.Context , dockerCli command.Cli , opts loadOptions ) error {
53
53
var input io.Reader = dockerCli .In ()
54
- if opts .input != "" {
54
+
55
+ // TODO(thaJeztah): add support for "-" as STDIN to match other commands, possibly making it a required positional argument.
56
+ switch opts .input {
57
+ case "" :
58
+ // To avoid getting stuck, verify that a tar file is given either in
59
+ // the input flag or through stdin and if not display an error message and exit.
60
+ if dockerCli .In ().IsTerminal () {
61
+ return errors .Errorf ("requested load from stdin, but stdin is empty" )
62
+ }
63
+ default :
55
64
// We use sequential.Open to use sequential file access on Windows, avoiding
56
65
// depleting the standby list un-necessarily. On Linux, this equates to a regular os.Open.
57
66
file , err := sequential .Open (opts .input )
@@ -62,12 +71,6 @@ func runLoad(ctx context.Context, dockerCli command.Cli, opts loadOptions) error
62
71
input = file
63
72
}
64
73
65
- // To avoid getting stuck, verify that a tar file is given either in
66
- // the input flag or through stdin and if not display an error message and exit.
67
- if opts .input == "" && dockerCli .In ().IsTerminal () {
68
- return errors .Errorf ("requested load from stdin, but stdin is empty" )
69
- }
70
-
71
74
var options []client.ImageLoadOption
72
75
if opts .quiet || ! dockerCli .Out ().IsTerminal () {
73
76
options = append (options , client .ImageLoadWithQuiet (true ))
0 commit comments