@@ -425,7 +425,7 @@ func runBasicBuild(ctx context.Context, dockerCli command.Cli, opts *cbuild.Opti
425425 return resp , dfmap , err
426426}
427427
428- func runControllerBuild (ctx context.Context , dockerCli command.Cli , opts * cbuild.Options , options buildOptions , printer * progress.Printer ) (* client.SolveResponse , * build.Inputs , error ) {
428+ func runControllerBuild (ctx context.Context , dockerCli command.Cli , opts * cbuild.Options , options buildOptions , printer * progress.Printer ) (_ * client.SolveResponse , _ * build.Inputs , retErr error ) {
429429 if options .invokeConfig != nil && (options .dockerfileName == "-" || options .contextPath == "-" ) {
430430 // stdin must be usable for monitor
431431 return nil , nil , errors .Errorf ("Dockerfile or context from stdin is not supported with invoke" )
@@ -434,29 +434,12 @@ func runControllerBuild(ctx context.Context, dockerCli command.Cli, opts *cbuild
434434 c := local .NewController (ctx , dockerCli )
435435 defer c .Close ()
436436
437- var (
438- ref string
439- retErr error
440-
441- f * ioset.SingleForwarder
442- pr io.ReadCloser
443- pw io.WriteCloser
444- )
445-
437+ var in io.ReadCloser
446438 if options .invokeConfig == nil {
447- pr = dockerCli .In ()
448- } else {
449- f = ioset .NewSingleForwarder ()
450- f .SetReader (dockerCli .In ())
451- pr , pw = io .Pipe ()
452- f .SetWriter (pw , func () io.WriteCloser {
453- pw .Close () // propagate EOF
454- logrus .Debug ("propagating stdin close" )
455- return nil
456- })
439+ in = dockerCli .In ()
457440 }
458441
459- resp , inputs , err := c .Build (ctx , opts , pr , printer )
442+ resp , inputs , err := c .Build (ctx , opts , in , printer )
460443 if err != nil {
461444 var be * controllererrors.BuildError
462445 if errors .As (err , & be ) {
@@ -467,28 +450,26 @@ func runControllerBuild(ctx context.Context, dockerCli command.Cli, opts *cbuild
467450 }
468451 }
469452
470- if options .invokeConfig != nil {
471- if err := pw .Close (); err != nil {
472- logrus .Debug ("failed to close stdin pipe writer" )
473- }
474- if err := pr .Close (); err != nil {
475- logrus .Debug ("failed to close stdin pipe reader" )
476- }
477- }
478-
479453 if options .invokeConfig != nil && options .invokeConfig .needsDebug (retErr ) {
480454 // Print errors before launching monitor
481455 if err := printError (retErr , printer ); err != nil {
482456 logrus .Warnf ("failed to print error information: %v" , err )
483457 }
484458
485- pr2 , pw2 := io .Pipe ()
486- f .SetWriter (pw2 , func () io.WriteCloser {
487- pw2 .Close () // propagate EOF
459+ pr , pw := io .Pipe ()
460+
461+ f := ioset .NewSingleForwarder ()
462+ f .SetReader (dockerCli .In ())
463+ f .SetWriter (pw , func () io.WriteCloser {
464+ pw .Close () // propagate EOF
488465 return nil
489466 })
490- monitorBuildResult , err := options .invokeConfig .runDebug (ctx , ref , opts , c , pr2 , os .Stdout , os .Stderr , printer )
491- if err := pw2 .Close (); err != nil {
467+
468+ // TODO: ref was never set to a value in the original code. Removed the variable to
469+ // reduce confusion but it also probably means this call is wrong in some way.
470+ // This area should be removed during the refactor anyway so it doesn't matter that much.
471+ monitorBuildResult , err := options .invokeConfig .runDebug (ctx , "" , opts , c , pr , os .Stdout , os .Stderr , printer )
472+ if err := pw .Close (); err != nil {
492473 logrus .Debug ("failed to close monitor stdin pipe reader" )
493474 }
494475 if err != nil {
0 commit comments