move error locally instead of utils/errors
This commit is contained in:
parent
73b5c37da7
commit
edb9f29f9d
@ -15,15 +15,18 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
cerrors "github.com/coreos/clair/utils/errors"
|
|
||||||
"github.com/fernet/fernet-go"
|
"github.com/fernet/fernet-go"
|
||||||
"gopkg.in/yaml.v2"
|
"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
|
// File represents a YAML configuration file that namespaces all Clair
|
||||||
// configuration under the top-level "clair" key.
|
// configuration under the top-level "clair" key.
|
||||||
type File struct {
|
type File struct {
|
||||||
@ -114,7 +117,7 @@ func Load(path string) (config *Config, err error) {
|
|||||||
config = &cfgFile.Clair
|
config = &cfgFile.Clair
|
||||||
|
|
||||||
if config.Database.Source == "" {
|
if config.Database.Source == "" {
|
||||||
err = cerrors.ErrDatasourceNotLoaded
|
err = ErrDatasourceNotLoaded
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
cerrors "github.com/coreos/clair/utils/errors"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -59,7 +58,7 @@ func TestLoadWrongConfiguration(t *testing.T) {
|
|||||||
|
|
||||||
_, err = Load(tmpfile.Name())
|
_, err = Load(tmpfile.Name())
|
||||||
|
|
||||||
assert.EqualError(t, err, cerrors.ErrDatasourceNotLoaded.Error())
|
assert.EqualError(t, err, ErrDatasourceNotLoaded.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoad(t *testing.T) {
|
func TestLoad(t *testing.T) {
|
||||||
|
@ -29,9 +29,6 @@ var (
|
|||||||
|
|
||||||
// ErrCouldNotParse is returned when a fetcher fails to parse the update data.
|
// ErrCouldNotParse is returned when a fetcher fails to parse the update data.
|
||||||
ErrCouldNotParse = errors.New("updater/fetchers: could not parse")
|
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.
|
// ErrBadRequest occurs when a method has been passed an inappropriate argument.
|
||||||
|
Loading…
Reference in New Issue
Block a user