(ctx context.Context, out io.Writer, mode progressui.DisplayMode, opts ...PrinterOpt)
| 122 | } |
| 123 | |
| 124 | func NewPrinter(ctx context.Context, out io.Writer, mode progressui.DisplayMode, opts ...PrinterOpt) (*Printer, error) { |
| 125 | opt := &printerOpts{} |
| 126 | for _, o := range opts { |
| 127 | o(opt) |
| 128 | } |
| 129 | |
| 130 | if v := os.Getenv("BUILDKIT_PROGRESS"); v != "" && mode == progressui.AutoMode { |
| 131 | mode = progressui.DisplayMode(v) |
| 132 | } |
| 133 | |
| 134 | d, err := progressui.NewDisplay(out, mode, opt.displayOpts...) |
| 135 | if err != nil { |
| 136 | return nil, err |
| 137 | } |
| 138 | |
| 139 | pw := &Printer{ |
| 140 | out: out, |
| 141 | mode: mode, |
| 142 | opt: opt, |
| 143 | status: make(chan *client.SolveStatus), |
| 144 | interrupt: make(chan interruptRequest), |
| 145 | state: printerStateRunning, |
| 146 | done: make(chan struct{}), |
| 147 | metrics: opt.mw, |
| 148 | } |
| 149 | go pw.run(ctx, d) |
| 150 | |
| 151 | return pw, nil |
| 152 | } |
| 153 | |
| 154 | func (p *Printer) run(ctx context.Context, d progressui.Display) { |
| 155 | defer close(p.done) |
no test coverage detected
searching dependent graphs…