Update go-toml to v2

Updates host file parsing to use new v2 method rather than the removed
toml.Tree.

Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
Derek McGowan
2023-09-22 12:29:26 -07:00
parent e0e6f870b7
commit b5615caf11
78 changed files with 7586 additions and 5876 deletions

View File

@@ -53,9 +53,6 @@ type Runtime struct {
// Currently, only device plugins populate the annotations.
ContainerAnnotations []string `toml:"container_annotations" json:"ContainerAnnotations"`
// Options are config options for the runtime.
// If options is loaded from toml config, it will be map[string]interface{}.
// Options can be converted into toml.Tree using toml.TreeFromMap().
// Using options type as map[string]interface{} helps in correctly marshaling options from Go to JSON.
Options map[string]interface{} `toml:"options" json:"options"`
// PrivilegedWithoutHostDevices overloads the default behaviour for adding host devices to the
// runtime spec when the container is privileged. Defaults to false.

View File

@@ -23,7 +23,7 @@ import (
"github.com/containerd/containerd"
"github.com/containerd/containerd/pkg/cri/streaming"
"github.com/pelletier/go-toml"
"github.com/pelletier/go-toml/v2"
)
// DefaultConfig returns default configurations of cri plugin.
@@ -53,7 +53,9 @@ func DefaultConfig() PluginConfig {
# CriuWorkPath is the criu work path.
CriuWorkPath = ""
`
tree, _ := toml.Load(defaultRuncV2Opts)
var m map[string]interface{}
toml.Unmarshal([]byte(defaultRuncV2Opts), &m)
return PluginConfig{
CniConfig: CniConfig{
NetworkPluginBinDir: "/opt/cni/bin",
@@ -68,7 +70,7 @@ func DefaultConfig() PluginConfig {
Runtimes: map[string]Runtime{
"runc": {
Type: "io.containerd.runc.v2",
Options: tree.ToMap(),
Options: m,
SandboxMode: string(ModePodSandbox),
},
},