Minor improvement

This commit is contained in:
TwinProduction 2020-06-25 21:31:34 -04:00
parent 3b309500c3
commit b05ae1c2d2

View File

@ -9,10 +9,9 @@ import (
"os" "os"
) )
type Config struct { const (
Metrics bool `yaml:"metrics"` DefaultConfigurationFilePath = "config/config.yaml"
Services []*core.Service `yaml:"services"` )
}
var ( var (
ErrNoServiceInConfig = errors.New("configuration file should contain at least 1 service") ErrNoServiceInConfig = errors.New("configuration file should contain at least 1 service")
@ -21,6 +20,11 @@ var (
config *Config config *Config
) )
type Config struct {
Metrics bool `yaml:"metrics"`
Services []*core.Service `yaml:"services"`
}
func Get() *Config { func Get() *Config {
if config == nil { if config == nil {
panic(ErrConfigNotLoaded) panic(ErrConfigNotLoaded)
@ -43,7 +47,7 @@ func Load(configFile string) error {
} }
func LoadDefaultConfiguration() error { func LoadDefaultConfiguration() error {
err := Load("config/config.yaml") err := Load(DefaultConfigurationFilePath)
if err != nil { if err != nil {
if err == ErrConfigFileNotFound { if err == ErrConfigFileNotFound {
return Load("config/config.yml") return Load("config/config.yml")