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

Function runEvents

cli/command/system/events.go:59–90  ·  view source on GitHub ↗
(ctx context.Context, dockerCLI command.Cli, options *eventsOptions)

Source from the content-addressed store, hash-verified

57}
58
59func runEvents(ctx context.Context, dockerCLI command.Cli, options *eventsOptions) error {
60 tmpl, err := makeTemplate(options.format)
61 if err != nil {
62 return cli.StatusError{
63 StatusCode: 64,
64 Status: "Error parsing format: " + err.Error(),
65 }
66 }
67 ctx, cancel := context.WithCancel(ctx)
68 eventRes := dockerCLI.Client().Events(ctx, client.EventsListOptions{
69 Since: options.since,
70 Until: options.until,
71 Filters: options.filter.Value(),
72 })
73 defer cancel()
74
75 out := dockerCLI.Out()
76
77 for {
78 select {
79 case event := <-eventRes.Messages:
80 if err := handleEvent(out, event, tmpl); err != nil {
81 return err
82 }
83 case err := <-eventRes.Err:
84 if err == io.EOF {
85 return nil
86 }
87 return err
88 }
89 }
90}
91
92func handleEvent(out io.Writer, event events.Message, tmpl *template.Template) error {
93 if tmpl == nil {

Callers 1

newEventsCommandFunction · 0.85

Calls 7

makeTemplateFunction · 0.85
handleEventFunction · 0.85
EventsMethod · 0.80
ClientMethod · 0.65
ValueMethod · 0.65
OutMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…