diff --git a/config/config.go b/config/config.go index f0260ef5..7e45c47a 100644 --- a/config/config.go +++ b/config/config.go @@ -15,15 +15,18 @@ package config import ( + "errors" "io/ioutil" "os" "time" - cerrors "github.com/coreos/clair/utils/errors" "github.com/fernet/fernet-go" "gopkg.in/yaml.v2" ) +// ErrDatasourceNotLoaded is returned when the datasource variable in the configuration file is not loaded properly +var ErrDatasourceNotLoaded = errors.New("could not load configuration: no database source specified") + // File represents a YAML configuration file that namespaces all Clair // configuration under the top-level "clair" key. type File struct { @@ -114,7 +117,7 @@ func Load(path string) (config *Config, err error) { config = &cfgFile.Clair if config.Database.Source == "" { - err = cerrors.ErrDatasourceNotLoaded + err = ErrDatasourceNotLoaded return } diff --git a/config/config_test.go b/config/config_test.go index abea170c..dec03fd2 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -6,7 +6,6 @@ import ( "os" "testing" - cerrors "github.com/coreos/clair/utils/errors" "github.com/stretchr/testify/assert" ) @@ -59,7 +58,7 @@ func TestLoadWrongConfiguration(t *testing.T) { _, err = Load(tmpfile.Name()) - assert.EqualError(t, err, cerrors.ErrDatasourceNotLoaded.Error()) + assert.EqualError(t, err, ErrDatasourceNotLoaded.Error()) } func TestLoad(t *testing.T) { diff --git a/utils/errors/errors.go b/utils/errors/errors.go index 00b7b089..65508f2b 100644 --- a/utils/errors/errors.go +++ b/utils/errors/errors.go @@ -29,9 +29,6 @@ var ( // ErrCouldNotParse is returned when a fetcher fails to parse the update data. ErrCouldNotParse = errors.New("updater/fetchers: could not parse") - - // ErrDatasourceNotLoaded is returned when the datasource variable in the configuration file is not loaded properly - ErrDatasourceNotLoaded = errors.New("could not load datasource configuration properly") ) // ErrBadRequest occurs when a method has been passed an inappropriate argument.