(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, opts eventsOpts, services []string)
| 57 | } |
| 58 | |
| 59 | func runEvents(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, opts eventsOpts, services []string) error { |
| 60 | name, err := opts.toProjectName(ctx, dockerCli) |
| 61 | if err != nil { |
| 62 | return err |
| 63 | } |
| 64 | |
| 65 | backend, err := compose.NewComposeService(dockerCli, backendOptions.Options...) |
| 66 | if err != nil { |
| 67 | return err |
| 68 | } |
| 69 | return backend.Events(ctx, name, api.EventsOptions{ |
| 70 | Services: services, |
| 71 | Since: opts.since, |
| 72 | Until: opts.until, |
| 73 | Consumer: func(event api.Event) error { |
| 74 | if opts.json { |
| 75 | marshal, err := json.Marshal(map[string]any{ |
| 76 | "time": event.Timestamp, |
| 77 | "type": "container", |
| 78 | "service": event.Service, |
| 79 | "id": event.Container, |
| 80 | "action": event.Status, |
| 81 | "attributes": event.Attributes, |
| 82 | }) |
| 83 | if err != nil { |
| 84 | return err |
| 85 | } |
| 86 | _, _ = fmt.Fprintln(dockerCli.Out(), string(marshal)) |
| 87 | } else { |
| 88 | _, _ = fmt.Fprintln(dockerCli.Out(), event) |
| 89 | } |
| 90 | return nil |
| 91 | }, |
| 92 | }) |
| 93 | } |
no test coverage detected