(timeNano int64, ctr *api.ContainerSummary, eventType int, opts ...func(e *api.ContainerEvent))
| 165 | } |
| 166 | |
| 167 | func newContainerEvent(timeNano int64, ctr *api.ContainerSummary, eventType int, opts ...func(e *api.ContainerEvent)) api.ContainerEvent { |
| 168 | name := ctr.Name |
| 169 | defaultName := getDefaultContainerName(ctr.Project, ctr.Labels[api.ServiceLabel], ctr.Labels[api.ContainerNumberLabel]) |
| 170 | if name == defaultName { |
| 171 | // remove project- prefix |
| 172 | name = name[len(ctr.Project)+1:] |
| 173 | } |
| 174 | |
| 175 | event := api.ContainerEvent{ |
| 176 | Type: eventType, |
| 177 | Container: ctr, |
| 178 | Time: timeNano, |
| 179 | Source: name, |
| 180 | ID: ctr.ID, |
| 181 | Service: ctr.Service, |
| 182 | ExitCode: ctr.ExitCode, |
| 183 | } |
| 184 | for _, opt := range opts { |
| 185 | opt(&event) |
| 186 | } |
| 187 | return event |
| 188 | } |
| 189 | |
| 190 | func (c *monitor) getContainerSummary(event events.Message) (*api.ContainerSummary, error) { |
| 191 | ctr := &api.ContainerSummary{ |
no test coverage detected