MCPcopy
hub / github.com/docker/compose / newContainerEvent

Function newContainerEvent

pkg/compose/monitor.go:167–188  ·  view source on GitHub ↗
(timeNano int64, ctr *api.ContainerSummary, eventType int, opts ...func(e *api.ContainerEvent))

Source from the content-addressed store, hash-verified

165}
166
167func 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
190func (c *monitor) getContainerSummary(event events.Message) (*api.ContainerSummary, error) {
191 ctr := &api.ContainerSummary{

Callers 1

StartMethod · 0.85

Calls 1

getDefaultContainerNameFunction · 0.85

Tested by

no test coverage detected