This type was added in 247f4796d21d98909974410ff27b61233776ae3a, and
at the time was added as an alias for string;
> api/types/events: add "Type" type for event-type enum
>
> Currently just an alias for string, but we can change it to be an
> actual type.
Now that all code uses the defined types, we should be able to make
this an actual type.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -60,7 +60,7 @@ func TestEventsErrorFromServer(t *testing.T) {
|
| 60 | 60 |
func TestEvents(t *testing.T) {
|
| 61 | 61 |
const expectedURL = "/events" |
| 62 | 62 |
|
| 63 |
- fltrs := filters.NewArgs(filters.Arg("type", events.ContainerEventType))
|
|
| 63 |
+ fltrs := filters.NewArgs(filters.Arg("type", string(events.ContainerEventType)))
|
|
| 64 | 64 |
expectedFiltersJSON := fmt.Sprintf(`{"type":{"%s":true}}`, events.ContainerEventType)
|
| 65 | 65 |
|
| 66 | 66 |
eventsCases := []struct {
|
| ... | ... |
@@ -722,7 +722,7 @@ func (c *containerConfig) applyPrivileges(hc *enginecontainer.HostConfig) {
|
| 722 | 722 |
|
| 723 | 723 |
func (c *containerConfig) eventFilter() filters.Args {
|
| 724 | 724 |
return filters.NewArgs( |
| 725 |
- filters.Arg("type", events.ContainerEventType),
|
|
| 725 |
+ filters.Arg("type", string(events.ContainerEventType)),
|
|
| 726 | 726 |
filters.Arg("name", c.name()),
|
| 727 | 727 |
filters.Arg("label", fmt.Sprintf("%v.task.id=%v", systemLabelPrefix, c.task.ID)),
|
| 728 | 728 |
) |
| ... | ... |
@@ -19,7 +19,7 @@ func NewFilter(filter filters.Args) *Filter {
|
| 19 | 19 |
// Include returns true when the event ev is included by the filters |
| 20 | 20 |
func (ef *Filter) Include(ev events.Message) bool {
|
| 21 | 21 |
return ef.matchEvent(ev) && |
| 22 |
- ef.filter.ExactMatch("type", ev.Type) &&
|
|
| 22 |
+ ef.filter.ExactMatch("type", string(ev.Type)) &&
|
|
| 23 | 23 |
ef.matchScope(ev.Scope) && |
| 24 | 24 |
ef.matchDaemon(ev) && |
| 25 | 25 |
ef.matchContainer(ev) && |
| ... | ... |
@@ -103,8 +103,7 @@ func (ef *Filter) matchConfig(ev events.Message) bool {
|
| 103 | 103 |
} |
| 104 | 104 |
|
| 105 | 105 |
func (ef *Filter) fuzzyMatchName(ev events.Message, eventType events.Type) bool {
|
| 106 |
- return ef.filter.FuzzyMatch(eventType, ev.Actor.ID) || |
|
| 107 |
- ef.filter.FuzzyMatch(eventType, ev.Actor.Attributes["name"]) |
|
| 106 |
+ return ef.filter.FuzzyMatch(string(eventType), ev.Actor.ID) || ef.filter.FuzzyMatch(string(eventType), ev.Actor.Attributes["name"]) |
|
| 108 | 107 |
} |
| 109 | 108 |
|
| 110 | 109 |
// matchImage matches against both event.Actor.ID (for image events) |
| ... | ... |
@@ -65,7 +65,7 @@ func Scan(text string) (*events.Message, error) {
|
| 65 | 65 |
return &events.Message{
|
| 66 | 66 |
Time: t, |
| 67 | 67 |
TimeNano: time.Unix(t, tn).UnixNano(), |
| 68 |
- Type: md["eventType"], |
|
| 68 |
+ Type: events.Type(md["eventType"]), |
|
| 69 | 69 |
Action: md["action"], |
| 70 | 70 |
Actor: events.Actor{
|
| 71 | 71 |
ID: md["id"], |
| ... | ... |
@@ -48,7 +48,7 @@ func TestPause(t *testing.T) {
|
| 48 | 48 |
messages, errs := apiClient.Events(ctx, types.EventsOptions{
|
| 49 | 49 |
Since: since, |
| 50 | 50 |
Until: until, |
| 51 |
- Filters: filters.NewArgs(filters.Arg(events.ContainerEventType, cID)), |
|
| 51 |
+ Filters: filters.NewArgs(filters.Arg(string(events.ContainerEventType), cID)), |
|
| 52 | 52 |
}) |
| 53 | 53 |
assert.Check(t, is.DeepEqual([]string{"pause", "unpause"}, getEventActions(t, messages, errs)))
|
| 54 | 54 |
} |