Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Commit

Permalink
Add 'all_events' option to the api to report all event types.
Browse files Browse the repository at this point in the history
  • Loading branch information
rjnagal committed May 6, 2015
1 parent 833a600 commit e68b6cb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
35 changes: 17 additions & 18 deletions api/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,28 +199,27 @@ func getEventRequest(r *http.Request) (*events.Request, bool, error) {
query.IncludeSubcontainers = newBool
}
}
if val, ok := urlMap["oom_events"]; ok {
eventTypes := map[string]info.EventType{
"oom_events": info.EventOom,
"oom_kill_events": info.EventOomKill,
"creation_events": info.EventContainerCreation,
"deletion_events": info.EventContainerDeletion,
}
allEventTypes := false
if val, ok := urlMap["all_events"]; ok {
newBool, err := strconv.ParseBool(val[0])
if err == nil {
query.EventType[info.EventOom] = newBool
allEventTypes = newBool
}
}
if val, ok := urlMap["oom_kill_events"]; ok {
newBool, err := strconv.ParseBool(val[0])
if err == nil {
query.EventType[info.EventOomKill] = newBool
}
}
if val, ok := urlMap["creation_events"]; ok {
newBool, err := strconv.ParseBool(val[0])
if err == nil {
query.EventType[info.EventContainerCreation] = newBool
}
}
if val, ok := urlMap["deletion_events"]; ok {
newBool, err := strconv.ParseBool(val[0])
if err == nil {
query.EventType[info.EventContainerDeletion] = newBool
for opt, eventType := range eventTypes {
if allEventTypes {
query.EventType[eventType] = true
} else if val, ok := urlMap[opt]; ok {
newBool, err := strconv.ParseBool(val[0])
if err == nil {
query.EventType[eventType] = newBool
}
}
}
if val, ok := urlMap["max_events"]; ok {
Expand Down
1 change: 1 addition & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ The endpoint accepts a certain number of query parameters:
| `stream` | Whether to stream new events as they occur. If false returns historical events | false |
| `subcontainers` | Whether to also return events for all subcontainers | false |
| `max_events` | The max number of events to return (for stream=false) | 10 |
| `all_events` | Whether to include all supported event types | false |
| `oom_events` | Whether to include OOM events | false |
| `oom_kill_events` | Whether to include OOM kill events | false |
| `creation_events` | Whether to include container creation events | false |
Expand Down

0 comments on commit e68b6cb

Please sign in to comment.