bufferDisplay will buffer display updates from the status channel into a slice. This method returns if either status gets closed or if an interrupt is received.
(ctx context.Context, ss []*client.SolveStatus)
| 229 | // |
| 230 | // This method returns if either status gets closed or if an interrupt is received. |
| 231 | func (p *Printer) bufferDisplay(ctx context.Context, ss []*client.SolveStatus) ([]*client.SolveStatus, error) { |
| 232 | for { |
| 233 | select { |
| 234 | case s, ok := <-p.status: |
| 235 | if !ok { |
| 236 | p.state = printerStateDone |
| 237 | return ss, nil |
| 238 | } |
| 239 | ss = append(ss, s) |
| 240 | case req := <-p.interrupt: |
| 241 | p.state = req.desiredState |
| 242 | req.close() |
| 243 | return ss, nil |
| 244 | case <-ctx.Done(): |
| 245 | p.state = printerStateDone |
| 246 | return nil, context.Cause(ctx) |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | func (p *Printer) WriteBuildRef(target string, ref string) { |
| 252 | p.buildRefsMu.Lock() |