@@ -20,8 +20,8 @@ import (
2020 "path/filepath"
2121 "strings"
2222
23- "github.com/BurntSushi/toml"
2423 "github.com/imdario/mergo"
24+ "github.com/pelletier/go-toml"
2525 "github.com/pkg/errors"
2626
2727 "github.com/containerd/containerd/errdefs"
@@ -55,7 +55,7 @@ type Config struct {
5555 // required plugin doesn't exist or fails to be initialized or started.
5656 RequiredPlugins []string `toml:"required_plugins"`
5757 // Plugins provides plugin specific configuration for the initialization of a plugin
58- Plugins map [string ]toml.Primitive `toml:"plugins"`
58+ Plugins map [string ]toml.Tree `toml:"plugins"`
5959 // OOMScore adjust the containerd's oom score
6060 OOMScore int `toml:"oom_score"`
6161 // Cgroup specifies cgroup information for the containerd daemon process
@@ -209,7 +209,7 @@ func (c *Config) Decode(p *plugin.Registration) (interface{}, error) {
209209 if ! ok {
210210 return p .Config , nil
211211 }
212- if err := toml . PrimitiveDecode ( data , p .Config ); err != nil {
212+ if err := data . Unmarshal ( p .Config ); err != nil {
213213 return nil , err
214214 }
215215 return p .Config , nil
@@ -264,10 +264,16 @@ func LoadConfig(path string, out *Config) error {
264264// loadConfigFile decodes a TOML file at the given path
265265func loadConfigFile (path string ) (* Config , error ) {
266266 config := & Config {}
267- _ , err := toml .DecodeFile (path , & config )
267+
268+ file , err := toml .LoadFile (path )
268269 if err != nil {
269- return nil , err
270+ return nil , errors . Wrapf ( err , "failed to load TOML: %s" , path )
270271 }
272+
273+ if err := file .Unmarshal (config ); err != nil {
274+ return nil , errors .Wrap (err , "failed to unmarshal TOML" )
275+ }
276+
271277 return config , nil
272278}
273279
0 commit comments