Browse code

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 <github@gone.nl>

Sebastiaan van Stijn authored on 2025/02/09 01:31:29
Showing 1 changed files
... ...
@@ -171,6 +171,7 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei
171 171
 		}
172 172
 
173 173
 		daemon.LogContainerEvent(c, events.ActionOOM)
174
+		return nil
174 175
 	case libcontainerdtypes.EventExit:
175 176
 		if ei.ProcessID == ei.ContainerID {
176 177
 			return daemon.handleContainerExit(c, &ei)
... ...
@@ -225,6 +226,7 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei
225 225
 			"execID":   ei.ProcessID,
226 226
 			"exitCode": strconv.Itoa(exitCode),
227 227
 		})
228
+		return nil
228 229
 	case libcontainerdtypes.EventStart:
229 230
 		c.Lock()
230 231
 		defer c.Unlock()
... ...
@@ -268,6 +270,7 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei
268 268
 			daemon.LogContainerEvent(c, events.ActionStart)
269 269
 		}
270 270
 
271
+		return nil
271 272
 	case libcontainerdtypes.EventPaused:
272 273
 		c.Lock()
273 274
 		defer c.Unlock()
... ...
@@ -281,6 +284,7 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei
281 281
 			}
282 282
 			daemon.LogContainerEvent(c, events.ActionPause)
283 283
 		}
284
+		return nil
284 285
 	case libcontainerdtypes.EventResumed:
285 286
 		c.Lock()
286 287
 		defer c.Unlock()
... ...
@@ -295,8 +299,11 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei
295 295
 			}
296 296
 			daemon.LogContainerEvent(c, events.ActionUnPause)
297 297
 		}
298
+		return nil
299
+	default:
300
+		// TODO(thaJeztah): make switch exhaustive; add types.EventUnknown, types.EventCreate, types.EventExecAdded, types.EventExecStarted
301
+		return nil
298 302
 	}
299
-	return nil
300 303
 }
301 304
 
302 305
 func (daemon *Daemon) autoRemove(cfg *config.Config, c *container.Container) {