From 75e2c46295b10f515757befb5bc02985df4c9498 Mon Sep 17 00:00:00 2001 From: Timofey Kirillov Date: Tue, 4 Apr 2023 18:20:19 +0300 Subject: [PATCH] build(cli): allow passing in-stream using command.Cli Use command.Cli::In() which is always initialized either to os.Stdin, or to user-specified stream: * https://github.com/docker/cli/blob/5be21394cbbafc5627bb3e8a54014c108a534b52/cli/command/cli.go#L494 * https://github.com/docker/cli/blob/master/cli/command/cli_options.go#L16C1-L26 Signed-off-by: Timofey Kirillov --- commands/build.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/build.go b/commands/build.go index 15355ce7..34ca483f 100644 --- a/commands/build.go +++ b/commands/build.go @@ -312,7 +312,7 @@ func getImageID(resp map[string]string) string { } func runBasicBuild(ctx context.Context, dockerCli command.Cli, opts *controllerapi.BuildOptions, options buildOptions, printer *progress.Printer) (*client.SolveResponse, error) { - resp, res, err := cbuild.RunBuild(ctx, dockerCli, *opts, os.Stdin, printer, false) + resp, res, err := cbuild.RunBuild(ctx, dockerCli, *opts, dockerCli.In(), printer, false) if res != nil { res.Done() } @@ -346,7 +346,7 @@ func runControllerBuild(ctx context.Context, dockerCli command.Cli, opts *contro var retErr error var resp *client.SolveResponse f := ioset.NewSingleForwarder() - f.SetReader(os.Stdin) + f.SetReader(dockerCli.In()) if !options.noBuild { pr, pw := io.Pipe() f.SetWriter(pw, func() io.WriteCloser {