mirror of
https://github.com/moby/moby.git
synced 2026-07-08 23:57:50 +00:00
daemon/cluster/executor/container: make switches exhaustive (exhaustive)
Adding a `default` statement so that disabling the "default-signifies-exhaustive"
linter option will make it show up.
daemon/cluster/executor/container/adapter.go:351:3: missing cases in switch of type api.Mount_MountType: api.MountTypeVolume, api.MountTypeTmpfs, api.MountTypeNamedPipe, api.MountTypeCluster (exhaustive)
switch mount.Type {
^
daemon/cluster/executor/container/adapter.go:540:4: missing cases in switch of type api.LogStream: api.LogStreamUnknown (exhaustive)
switch stream {
^
daemon/cluster/executor/container/container.go:715:3: missing cases in switch of type api.Privileges_SeccompOpts_SeccompMode: api.Privileges_SeccompOpts_DEFAULT (exhaustive)
switch seccomp.Mode {
^
daemon/cluster/executor/container/controller.go:257:4: missing cases in switch of type events.Action: events.ActionCreate, events.ActionStart, events.ActionRestart, events.ActionStop, events.ActionCheckpoint, events.ActionPause, events.ActionUnPause, events.ActionAttach, events.ActionDetach, events.ActionResize, events.ActionUpdate, events.ActionRename, events.ActionKill, events.ActionOOM, events.ActionRemove, events.ActionCommit, events.ActionTop, events.ActionCopy, events.ActionArchivePath, events.ActionExtractToDir, events.ActionExport, events.ActionImport, events.ActionSave, events.ActionLoad, events.ActionTag, events.ActionUnTag, events.ActionPush, events.ActionPull, events.ActionPrune, events.ActionDelete, events.ActionEnable, events.ActionDisable, events.ActionConnect, events.ActionDisconnect, events.ActionReload, events.ActionMount, events.ActionUnmount, events.ActionExecCreate, events.ActionExecStart, events.ActionExecDie, events.ActionExecDetach, events.ActionHealthStatus, events.ActionHealthStatusRunning (exhaustive)
switch event.Action {
^
daemon/cluster/executor/container/controller.go:480:4: missing cases in switch of type events.Action: events.ActionCreate, events.ActionStart, events.ActionRestart, events.ActionStop, events.ActionCheckpoint, events.ActionPause, events.ActionUnPause, events.ActionAttach, events.ActionDetach, events.ActionResize, events.ActionUpdate, events.ActionRename, events.ActionKill, events.ActionDie, events.ActionOOM, events.ActionDestroy, events.ActionRemove, events.ActionCommit, events.ActionTop, events.ActionCopy, events.ActionArchivePath, events.ActionExtractToDir, events.ActionExport, events.ActionImport, events.ActionSave, events.ActionLoad, events.ActionTag, events.ActionUnTag, events.ActionPush, events.ActionPull, events.ActionPrune, events.ActionDelete, events.ActionEnable, events.ActionDisable, events.ActionConnect, events.ActionDisconnect, events.ActionReload, events.ActionMount, events.ActionUnmount, events.ActionExecCreate, events.ActionExecStart, events.ActionExecDie, events.ActionExecDetach, events.ActionHealthStatus, events.ActionHealthStatusRunning, events.ActionHealthStatusHealthy, events.ActionHealthStatusUnhealthy (exhaustive)
switch event.Action {
^
daemon/cluster/executor/container/controller.go:723:4: missing cases in switch of type events.Action: events.ActionCreate, events.ActionStart, events.ActionRestart, events.ActionStop, events.ActionCheckpoint, events.ActionPause, events.ActionUnPause, events.ActionAttach, events.ActionDetach, events.ActionResize, events.ActionUpdate, events.ActionRename, events.ActionKill, events.ActionDie, events.ActionOOM, events.ActionDestroy, events.ActionRemove, events.ActionCommit, events.ActionTop, events.ActionCopy, events.ActionArchivePath, events.ActionExtractToDir, events.ActionExport, events.ActionImport, events.ActionSave, events.ActionLoad, events.ActionTag, events.ActionUnTag, events.ActionPush, events.ActionPull, events.ActionPrune, events.ActionDelete, events.ActionEnable, events.ActionDisable, events.ActionConnect, events.ActionDisconnect, events.ActionReload, events.ActionMount, events.ActionUnmount, events.ActionExecCreate, events.ActionExecStart, events.ActionExecDie, events.ActionExecDetach, events.ActionHealthStatus, events.ActionHealthStatusRunning, events.ActionHealthStatusHealthy (exhaustive)
switch event.Action {
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -353,6 +353,8 @@ func (c *containerAdapter) checkMounts() error {
|
||||
if _, err := os.Stat(mount.Source); os.IsNotExist(err) {
|
||||
return fmt.Errorf("invalid bind mount source, source path not found: %s", mount.Source)
|
||||
}
|
||||
default:
|
||||
// TODO(thaJeztah): make switch exhaustive; add api.MountTypeVolume, api.MountTypeTmpfs, api.MountTypeNamedPipe, api.MountTypeCluster
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,6 +544,8 @@ func (c *containerAdapter) logs(ctx context.Context, options api.LogSubscription
|
||||
apiOptions.ShowStdout = true
|
||||
case api.LogStreamStderr:
|
||||
apiOptions.ShowStderr = true
|
||||
default:
|
||||
// TODO(thaJeztah): make switch exhaustive; add api.LogStreamUnknown
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -722,6 +722,8 @@ func (c *containerConfig) applyPrivileges(hc *containertypes.HostConfig) {
|
||||
// Profile is bytes, but those bytes are actually a string. This is
|
||||
// basically verbatim what happens in the cli after a file is read.
|
||||
hc.SecurityOpt = append(hc.SecurityOpt, fmt.Sprintf("seccomp=%s", seccomp.Profile))
|
||||
default:
|
||||
// TODO(thaJeztah): make switch exhaustive; add api.Privileges_SeccompOpts_DEFAULT
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -281,6 +281,8 @@ func (r *controller) Start(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
default:
|
||||
// TODO(thaJeztah): make switch exhaustive
|
||||
}
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
@@ -467,6 +469,8 @@ func (r *controller) waitReady(pctx context.Context) error {
|
||||
switch ctnr.State.Status {
|
||||
case "running", "exited", "dead":
|
||||
return nil
|
||||
default:
|
||||
// TODO(thaJeztah): make switch exhaustive
|
||||
}
|
||||
}
|
||||
|
||||
@@ -480,6 +484,8 @@ func (r *controller) waitReady(pctx context.Context) error {
|
||||
switch event.Action {
|
||||
case "start":
|
||||
return nil
|
||||
default:
|
||||
// TODO(thaJeztah): make switch exhaustive
|
||||
}
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
@@ -719,9 +725,7 @@ func (r *controller) checkHealth(ctx context.Context) error {
|
||||
if !r.matchevent(event) {
|
||||
continue
|
||||
}
|
||||
|
||||
switch event.Action {
|
||||
case events.ActionHealthStatusUnhealthy:
|
||||
if event.Action == events.ActionHealthStatusUnhealthy {
|
||||
return ErrContainerUnhealthy
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user