feat: replace github.com/pkg/errors to errors

Signed-off-by: haoyun <yun.hao@daocloud.io>
Co-authored-by: zounengren <zouyee1989@gmail.com>
This commit is contained in:
haoyun
2022-01-07 10:19:31 +08:00
parent 3ccd43c8f6
commit bbe46b8c43
299 changed files with 1896 additions and 1874 deletions

View File

@@ -26,7 +26,6 @@ import (
"github.com/docker/go-units"
"github.com/hashicorp/go-multierror"
"github.com/pelletier/go-toml"
"github.com/pkg/errors"
)
// Config represents device mapper configuration loaded from file.
@@ -68,11 +67,11 @@ func LoadConfig(path string) (*Config, error) {
config := Config{}
file, err := toml.LoadFile(path)
if err != nil {
return nil, errors.Wrapf(err, "failed to open devmapepr TOML: %s", path)
return nil, fmt.Errorf("failed to open devmapepr TOML: %s: %w", path, err)
}
if err := file.Unmarshal(&config); err != nil {
return nil, errors.Wrap(err, "failed to unmarshal devmapper TOML")
return nil, fmt.Errorf("failed to unmarshal devmapper TOML: %w", err)
}
if err := config.parse(); err != nil {
@@ -89,7 +88,7 @@ func LoadConfig(path string) (*Config, error) {
func (c *Config) parse() error {
baseImageSize, err := units.RAMInBytes(c.BaseImageSize)
if err != nil {
return errors.Wrapf(err, "failed to parse base image size: '%s'", c.BaseImageSize)
return fmt.Errorf("failed to parse base image size: '%s': %w", c.BaseImageSize, err)
}
if c.FileSystemType == "" {