daemon: inline copyAttributes utilty

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2026-01-05 12:41:41 +01:00
parent 8a01dc2f90
commit dcb0149ee1

View File

@@ -24,7 +24,9 @@ func (daemon *Daemon) LogContainerEvent(container *container.Container, action e
// LogContainerEventWithAttributes generates an event related to a container with specific given attributes.
func (daemon *Daemon) LogContainerEventWithAttributes(container *container.Container, action events.Action, attributes map[string]string) {
copyAttributes(attributes, container.Config.Labels)
if container.Config.Labels != nil {
maps.Copy(attributes, container.Config.Labels)
}
if container.Config.Image != "" {
attributes["image"] = container.Config.Image
}
@@ -90,14 +92,6 @@ func (daemon *Daemon) UnsubscribeFromEvents(listener chan any) {
daemon.EventsService.Evict(listener)
}
// copyAttributes guarantees that labels are not mutated by event triggers.
func copyAttributes(attributes, labels map[string]string) {
if labels == nil {
return
}
maps.Copy(attributes, labels)
}
// ProcessClusterNotifications gets changes from store and add them to event list
func (daemon *Daemon) ProcessClusterNotifications(ctx context.Context, watchStream chan *swarmapi.WatchMessage) {
for {