MCPcopy Index your code
hub / github.com/docker/cli / Display

Function Display

internal/jsonstream/display.go:50–69  ·  view source on GitHub ↗

Display prints the JSON messages from the given reader to the given stream. It wraps the [jsonmessage.DisplayJSONMessagesStream] function to make it "context aware" and appropriately returns why the function was canceled. It returns an error if the context is canceled, but not if the input reader

(ctx context.Context, in io.Reader, stream *streams.Out, opts ...Options)

Source from the content-addressed store, hash-verified

48//
49// It returns an error if the context is canceled, but not if the input reader / stream is closed.
50func Display(ctx context.Context, in io.Reader, stream *streams.Out, opts ...Options) error {
51 if ctx.Err() != nil {
52 return ctx.Err()
53 }
54
55 reader := &ctxReader{err: make(chan error, 1), r: in}
56 stopFunc := context.AfterFunc(ctx, func() { reader.err <- ctx.Err() })
57 defer stopFunc()
58
59 o := options{}
60 for _, opt := range opts {
61 opt(&o)
62 }
63
64 if err := jsonmessage.DisplayJSONMessagesStream(reader, stream, stream.FD(), stream.IsTerminal(), o.AuxCallback); err != nil {
65 return err
66 }
67
68 return ctx.Err()
69}

Callers 1

TestDisplayFunction · 0.85

Calls 3

ErrMethod · 0.65
FDMethod · 0.45
IsTerminalMethod · 0.45

Tested by 1

TestDisplayFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…