Skip to content

Commit 9d53f92

Browse files
Fix(progress): implement Fd() in console wrapper to restore Windows TTY
Signed-off-by: maishivamhoo123 <maishivamhoo@gmail.com>
1 parent 3d970a2 commit 9d53f92

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

pkg/compose/build_bake.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,9 @@ func (s *composeService) getBuildxPlugin() (*manager.Plugin, error) {
435435
// buildkit's NewDisplay doesn't actually require a [io.Reader], it only uses the [containerd.Console] type to
436436
// benefits from ANSI capabilities, but only does writes.
437437
func makeConsole(out io.Writer) io.Writer {
438+
if s, ok := out.(*streams.Out); ok {
439+
return &_console{s}
440+
}
438441
return out
439442
}
440443

@@ -444,21 +447,25 @@ type _console struct {
444447
*streams.Out
445448
}
446449

447-
func (c _console) Read(p []byte) (n int, err error) {
450+
func (c *_console) Read(p []byte) (n int, err error) {
448451
return 0, errors.New("not implemented")
449452
}
450453

451-
func (c _console) Close() error {
454+
func (c *_console) Close() error {
452455
return nil
453456
}
454457

455-
func (c _console) Fd() uintptr {
458+
func (c *_console) Fd() uintptr {
456459
return c.FD()
457460
}
458461

459-
func (c _console) Name() string {
462+
func (c *_console) Name() string {
460463
return "compose"
461464
}
465+
func (c *_console) File() *os.File {
466+
// streams.Out wraps the actual file. We attempt to unwrap it.
467+
return os.NewFile(c.Out.FD(), "compose")
468+
}
462469

463470
func toBakeExtraHosts(hosts types.HostsList) map[string]string {
464471
m := make(map[string]string)

0 commit comments

Comments
 (0)