From dcb0149ee1430bc1d6f360c7912810194bf22808 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 5 Jan 2026 12:41:41 +0100 Subject: [PATCH] daemon: inline copyAttributes utilty Signed-off-by: Sebastiaan van Stijn --- daemon/events.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/daemon/events.go b/daemon/events.go index dc8f81d879..40e19fb8c9 100644 --- a/daemon/events.go +++ b/daemon/events.go @@ -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 {