Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion cmd/compose/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ import (

type eventsOpts struct {
*composeOptions
json bool
json bool
since string
until string
}

func eventsCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
Expand All @@ -48,6 +50,8 @@ func eventsCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service
}

cmd.Flags().BoolVar(&opts.json, "json", false, "Output events as a stream of json objects")
cmd.Flags().StringVar(&opts.since, "since", "", "Show all events created since timestamp")
cmd.Flags().StringVar(&opts.until, "until", "", "Stream events until this timestamp")
return cmd
}

Expand All @@ -59,6 +63,8 @@ func runEvents(ctx context.Context, dockerCli command.Cli, backend api.Service,

return backend.Events(ctx, name, api.EventsOptions{
Services: services,
Since: opts.since,
Until: opts.until,
Consumer: func(event api.Event) error {
if opts.json {
marshal, err := json.Marshal(map[string]interface{}{
Expand Down
10 changes: 6 additions & 4 deletions docs/reference/compose_events.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ The events that can be received using this can be seen [here](/reference/cli/doc

### Options

| Name | Type | Default | Description |
|:------------|:-------|:--------|:------------------------------------------|
| `--dry-run` | `bool` | | Execute command in dry run mode |
| `--json` | `bool` | | Output events as a stream of json objects |
| Name | Type | Default | Description |
|:------------|:---------|:--------|:------------------------------------------|
| `--dry-run` | `bool` | | Execute command in dry run mode |
| `--json` | `bool` | | Output events as a stream of json objects |
| `--since` | `string` | | Show all events created since timestamp |
| `--until` | `string` | | Stream events until this timestamp |


<!---MARKER_GEN_END-->
Expand Down
18 changes: 18 additions & 0 deletions docs/reference/docker_compose_events.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,24 @@ options:
experimentalcli: false
kubernetes: false
swarm: false
- option: since
value_type: string
description: Show all events created since timestamp
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: until
value_type: string
description: Stream events until this timestamp
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
inherited_options:
- option: dry-run
value_type: bool
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ type AttachOptions struct {
type EventsOptions struct {
Services []string
Consumer func(event Event) error
Since string
Until string
}

// Event is a container runtime event served by Events API
Expand Down
2 changes: 2 additions & 0 deletions pkg/compose/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ func (s *composeService) Events(ctx context.Context, projectName string, options
projectName = strings.ToLower(projectName)
evts, errors := s.apiClient().Events(ctx, events.ListOptions{
Filters: filters.NewArgs(projectFilter(projectName)),
Since: options.Since,
Until: options.Until,
})
for {
select {
Expand Down