From 10ebdbbb925a8086022c04da32c3a41b277f57e3 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 8 Feb 2025 17:31:29 +0100 Subject: [PATCH] daemon: Daemon.ProcessEvent: make switches exhaustive (exhaustive) Adding a `default` statement so that disabling the "default-signifies-exhaustive" linter option will make it show up. daemon/monitor.go:158:2: missing cases in switch of type types.EventType: types.EventUnknown, types.EventCreate, types.EventExecAdded, types.EventExecStarted (exhaustive) switch e { ^ Signed-off-by: Sebastiaan van Stijn --- daemon/monitor.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/daemon/monitor.go b/daemon/monitor.go index abd32c52b9..e6e2dfc6fe 100644 --- a/daemon/monitor.go +++ b/daemon/monitor.go @@ -171,6 +171,7 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei } daemon.LogContainerEvent(c, events.ActionOOM) + return nil case libcontainerdtypes.EventExit: if ei.ProcessID == ei.ContainerID { return daemon.handleContainerExit(c, &ei) @@ -225,6 +226,7 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei "execID": ei.ProcessID, "exitCode": strconv.Itoa(exitCode), }) + return nil case libcontainerdtypes.EventStart: c.Lock() defer c.Unlock() @@ -268,6 +270,7 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei daemon.LogContainerEvent(c, events.ActionStart) } + return nil case libcontainerdtypes.EventPaused: c.Lock() defer c.Unlock() @@ -281,6 +284,7 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei } daemon.LogContainerEvent(c, events.ActionPause) } + return nil case libcontainerdtypes.EventResumed: c.Lock() defer c.Unlock() @@ -295,8 +299,11 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei } daemon.LogContainerEvent(c, events.ActionUnPause) } + return nil + default: + // TODO(thaJeztah): make switch exhaustive; add types.EventUnknown, types.EventCreate, types.EventExecAdded, types.EventExecStarted + return nil } - return nil } func (daemon *Daemon) autoRemove(cfg *config.Config, c *container.Container) {