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

Method LoadImage

util/dockerutil/client.go:35–74  ·  view source on GitHub ↗

LoadImage imports an image to docker.

(ctx context.Context, name string, status progress.Writer)

Source from the content-addressed store, hash-verified

33
34// LoadImage imports an image to docker.
35func (c *Client) LoadImage(ctx context.Context, name string, status progress.Writer) (io.WriteCloser, func(), error) {
36 dapi, err := c.API(name)
37 if err != nil {
38 return nil, nil, err
39 }
40
41 pr, pw := io.Pipe()
42 done := make(chan struct{})
43
44 var w *waitingWriter
45 w = &waitingWriter{
46 PipeWriter: pw,
47 f: func() {
48 handleErr := func(err error) {
49 pr.CloseWithError(err)
50 w.mu.Lock()
51 w.err = err
52 w.mu.Unlock()
53 }
54
55 resp, err := dapi.ImageLoad(ctx, pr)
56 defer close(done)
57 if err != nil {
58 handleErr(err)
59 return
60 }
61
62 status = progress.ResetTime(status)
63 if err := progress.Wrap("importing to docker", status.Write, func(l progress.SubLogger) error {
64 return fromReader(l, resp)
65 }); err != nil {
66 handleErr(err)
67 }
68 },
69 done: done,
70 }
71 return w, func() {
72 pr.Close()
73 }, nil
74}
75
76func (c *Client) Features(ctx context.Context, name string) map[Feature]bool {
77 c.featuresOnce.Do(func() {

Callers

nothing calls this directly

Calls 5

APIMethod · 0.95
ResetTimeFunction · 0.92
WrapFunction · 0.92
fromReaderFunction · 0.85
CloseMethod · 0.45

Tested by

no test coverage detected