Migrate current TOML code to github.com/pelletier/go-toml
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
@@ -20,8 +20,8 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/imdario/mergo"
|
||||
"github.com/pelletier/go-toml"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
@@ -55,7 +55,7 @@ type Config struct {
|
||||
// required plugin doesn't exist or fails to be initialized or started.
|
||||
RequiredPlugins []string `toml:"required_plugins"`
|
||||
// Plugins provides plugin specific configuration for the initialization of a plugin
|
||||
Plugins map[string]toml.Primitive `toml:"plugins"`
|
||||
Plugins map[string]toml.Tree `toml:"plugins"`
|
||||
// OOMScore adjust the containerd's oom score
|
||||
OOMScore int `toml:"oom_score"`
|
||||
// Cgroup specifies cgroup information for the containerd daemon process
|
||||
@@ -209,7 +209,7 @@ func (c *Config) Decode(p *plugin.Registration) (interface{}, error) {
|
||||
if !ok {
|
||||
return p.Config, nil
|
||||
}
|
||||
if err := toml.PrimitiveDecode(data, p.Config); err != nil {
|
||||
if err := data.Unmarshal(p.Config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return p.Config, nil
|
||||
@@ -264,10 +264,16 @@ func LoadConfig(path string, out *Config) error {
|
||||
// loadConfigFile decodes a TOML file at the given path
|
||||
func loadConfigFile(path string) (*Config, error) {
|
||||
config := &Config{}
|
||||
_, err := toml.DecodeFile(path, &config)
|
||||
|
||||
file, err := toml.LoadFile(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrapf(err, "failed to load TOML: %s", path)
|
||||
}
|
||||
|
||||
if err := file.Unmarshal(config); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to unmarshal TOML")
|
||||
}
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user