MCPcopy Create free account
hub / github.com/docker/buildx / Invoke

Method Invoke

monitor/monitor.go:342–368  ·  view source on GitHub ↗
(ctx context.Context, pid string, cfg *build.InvokeConfig, ioIn io.ReadCloser, ioOut io.WriteCloser, ioErr io.WriteCloser)

Source from the content-addressed store, hash-verified

340}
341
342func (m *monitor) Invoke(ctx context.Context, pid string, cfg *build.InvokeConfig, ioIn io.ReadCloser, ioOut io.WriteCloser, ioErr io.WriteCloser) error {
343 proc, ok := m.processes.Get(pid)
344 if !ok {
345 // Start a new process.
346 if m.rCtx == nil {
347 return errors.New("no build result is registered")
348 }
349 var err error
350 proc, err = m.processes.StartProcess(pid, m.rCtx, cfg)
351 if err != nil {
352 return err
353 }
354 }
355
356 // Attach containerIn to this process
357 ioCancelledCh := make(chan struct{})
358 proc.ForwardIO(&ioset.In{Stdin: ioIn, Stdout: ioOut, Stderr: ioErr}, func(error) { close(ioCancelledCh) })
359
360 select {
361 case <-ioCancelledCh:
362 return errors.Errorf("io cancelled")
363 case err := <-proc.Done():
364 return err
365 case <-ctx.Done():
366 return context.Cause(ctx)
367 }
368}
369
370func (m *monitor) Rollback(ctx context.Context, cfg *build.InvokeConfig) string {
371 pid := identity.NewID()

Callers 1

invokeMethod · 0.95

Calls 5

StartProcessMethod · 0.80
ForwardIOMethod · 0.80
DoneMethod · 0.80
GetMethod · 0.65
NewMethod · 0.65

Tested by

no test coverage detected