Address singleCaseSwitch errors

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar 2023-08-25 17:34:30 +02:00
parent f8870b31be
commit 2f48ab99c3
4 changed files with 4 additions and 8 deletions

View File

@ -146,8 +146,7 @@ func (c *configToml) setFlagToKeyValue(setFlag string) (string, interface{}, err
if v == nil { if v == nil {
return key, nil, errInvalidConfigOption return key, nil, errInvalidConfigOption
} }
switch v.(type) { if _, ok := v.(bool); ok {
case bool:
if len(setParts) == 1 { if len(setParts) == 1 {
return key, true, nil return key, true, nil
} }

View File

@ -38,8 +38,7 @@ func (c *ConfigV1) AddRuntime(name string, path string, setAsDefault bool) error
config.Set("version", int64(1)) config.Set("version", int64(1))
switch runc := config.GetPath([]string{"plugins", "cri", "containerd", "runtimes", "runc"}).(type) { if runc, ok := config.GetPath([]string{"plugins", "cri", "containerd", "runtimes", "runc"}).(*toml.Tree); ok {
case *toml.Tree:
runc, _ = toml.Load(runc.String()) runc, _ = toml.Load(runc.String())
config.SetPath([]string{"plugins", "cri", "containerd", "runtimes", name}, runc) config.SetPath([]string{"plugins", "cri", "containerd", "runtimes", name}, runc)
} }

View File

@ -32,8 +32,7 @@ func (c *Config) AddRuntime(name string, path string, setAsDefault bool) error {
config.Set("version", int64(2)) config.Set("version", int64(2))
switch runc := config.GetPath([]string{"plugins", "io.containerd.grpc.v1.cri", "containerd", "runtimes", "runc"}).(type) { if runc, ok := config.GetPath([]string{"plugins", "io.containerd.grpc.v1.cri", "containerd", "runtimes", "runc"}).(*toml.Tree); ok {
case *toml.Tree:
runc, _ = toml.Load(runc.String()) runc, _ = toml.Load(runc.String())
config.SetPath([]string{"plugins", "io.containerd.grpc.v1.cri", "containerd", "runtimes", name}, runc) config.SetPath([]string{"plugins", "io.containerd.grpc.v1.cri", "containerd", "runtimes", name}, runc)
} }

View File

@ -44,8 +44,7 @@ func (c *Config) AddRuntime(name string, path string, setAsDefault bool) error {
config := (toml.Tree)(*c) config := (toml.Tree)(*c)
switch runc := config.Get("crio.runtime.runtimes.runc").(type) { if runc, ok := config.Get("crio.runtime.runtimes.runc").(*toml.Tree); ok {
case *toml.Tree:
runc, _ = toml.Load(runc.String()) runc, _ = toml.Load(runc.String())
config.SetPath([]string{"crio", "runtime", "runtimes", name}, runc) config.SetPath([]string{"crio", "runtime", "runtimes", name}, runc)
} }