Remove hashicorp/go-multierror

Signed-off-by: Jin Dong <jin.dong@databricks.com>
This commit is contained in:
Jin Dong
2023-08-19 00:33:26 -07:00
parent 89553637a7
commit cd8c8ae4bc
14 changed files with 101 additions and 117 deletions

View File

@@ -19,11 +19,11 @@
package devmapper
import (
"errors"
"fmt"
"os"
"github.com/docker/go-units"
"github.com/hashicorp/go-multierror"
"github.com/pelletier/go-toml"
)
@@ -100,29 +100,29 @@ func (c *Config) parse() error {
// Validate makes sure configuration fields are valid
func (c *Config) Validate() error {
var result *multierror.Error
var result []error
if c.PoolName == "" {
result = multierror.Append(result, fmt.Errorf("pool_name is required"))
result = append(result, fmt.Errorf("pool_name is required"))
}
if c.RootPath == "" {
result = multierror.Append(result, fmt.Errorf("root_path is required"))
result = append(result, fmt.Errorf("root_path is required"))
}
if c.BaseImageSize == "" {
result = multierror.Append(result, fmt.Errorf("base_image_size is required"))
result = append(result, fmt.Errorf("base_image_size is required"))
}
if c.FileSystemType != "" {
switch c.FileSystemType {
case fsTypeExt4, fsTypeXFS, fsTypeExt2:
default:
result = multierror.Append(result, fmt.Errorf("unsupported Filesystem Type: %q", c.FileSystemType))
result = append(result, fmt.Errorf("unsupported Filesystem Type: %q", c.FileSystemType))
}
} else {
result = multierror.Append(result, fmt.Errorf("filesystem type cannot be empty"))
result = append(result, fmt.Errorf("filesystem type cannot be empty"))
}
return result.ErrorOrNil()
return errors.Join(result...)
}