Migrate current TOML code to github.com/pelletier/go-toml

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
Maksym Pavlenko
2021-03-25 13:13:33 -07:00
parent 499c2f7d4a
commit ddd4298a10
8 changed files with 34 additions and 21 deletions

View File

@@ -22,9 +22,9 @@ import (
"fmt"
"os"
"github.com/BurntSushi/toml"
"github.com/docker/go-units"
"github.com/hashicorp/go-multierror"
"github.com/pelletier/go-toml"
"github.com/pkg/errors"
)
@@ -56,8 +56,13 @@ func LoadConfig(path string) (*Config, error) {
}
config := Config{}
if _, err := toml.DecodeFile(path, &config); err != nil {
return nil, errors.Wrapf(err, "failed to unmarshal data at '%s'", path)
file, err := toml.LoadFile(path)
if err != nil {
return nil, errors.Wrapf(err, "failed to open devmapepr TOML: %s", path)
}
if err := file.Unmarshal(&config); err != nil {
return nil, errors.Wrap(err, "failed to unmarshal devmapper TOML")
}
if err := config.parse(); err != nil {

View File

@@ -23,8 +23,8 @@ import (
"os"
"testing"
"github.com/BurntSushi/toml"
"github.com/hashicorp/go-multierror"
"github.com/pelletier/go-toml"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)