diff --git a/cmd/nvidia-ctk/config/config.go b/cmd/nvidia-ctk/config/config.go index f6d636fc..17cf1e06 100644 --- a/cmd/nvidia-ctk/config/config.go +++ b/cmd/nvidia-ctk/config/config.go @@ -146,8 +146,7 @@ func (c *configToml) setFlagToKeyValue(setFlag string) (string, interface{}, err if v == nil { return key, nil, errInvalidConfigOption } - switch v.(type) { - case bool: + if _, ok := v.(bool); ok { if len(setParts) == 1 { return key, true, nil } diff --git a/pkg/config/engine/containerd/config_v1.go b/pkg/config/engine/containerd/config_v1.go index b432f60b..c2343941 100644 --- a/pkg/config/engine/containerd/config_v1.go +++ b/pkg/config/engine/containerd/config_v1.go @@ -38,8 +38,7 @@ func (c *ConfigV1) AddRuntime(name string, path string, setAsDefault bool) error config.Set("version", int64(1)) - switch runc := config.GetPath([]string{"plugins", "cri", "containerd", "runtimes", "runc"}).(type) { - case *toml.Tree: + if runc, ok := config.GetPath([]string{"plugins", "cri", "containerd", "runtimes", "runc"}).(*toml.Tree); ok { runc, _ = toml.Load(runc.String()) config.SetPath([]string{"plugins", "cri", "containerd", "runtimes", name}, runc) } diff --git a/pkg/config/engine/containerd/config_v2.go b/pkg/config/engine/containerd/config_v2.go index 3fcdb9c5..35205446 100644 --- a/pkg/config/engine/containerd/config_v2.go +++ b/pkg/config/engine/containerd/config_v2.go @@ -32,8 +32,7 @@ func (c *Config) AddRuntime(name string, path string, setAsDefault bool) error { config.Set("version", int64(2)) - switch runc := config.GetPath([]string{"plugins", "io.containerd.grpc.v1.cri", "containerd", "runtimes", "runc"}).(type) { - case *toml.Tree: + if runc, ok := config.GetPath([]string{"plugins", "io.containerd.grpc.v1.cri", "containerd", "runtimes", "runc"}).(*toml.Tree); ok { runc, _ = toml.Load(runc.String()) config.SetPath([]string{"plugins", "io.containerd.grpc.v1.cri", "containerd", "runtimes", name}, runc) } diff --git a/pkg/config/engine/crio/crio.go b/pkg/config/engine/crio/crio.go index 03db8bff..dcf8572a 100644 --- a/pkg/config/engine/crio/crio.go +++ b/pkg/config/engine/crio/crio.go @@ -44,8 +44,7 @@ func (c *Config) AddRuntime(name string, path string, setAsDefault bool) error { config := (toml.Tree)(*c) - switch runc := config.Get("crio.runtime.runtimes.runc").(type) { - case *toml.Tree: + if runc, ok := config.Get("crio.runtime.runtimes.runc").(*toml.Tree); ok { runc, _ = toml.Load(runc.String()) config.SetPath([]string{"crio", "runtime", "runtimes", name}, runc) }