config: fix default fallback
This commit is contained in:
parent
19b730ea67
commit
20af787437
@ -66,28 +66,31 @@ type APIConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DefaultConfig is a configuration that can be used as a fallback value.
|
// DefaultConfig is a configuration that can be used as a fallback value.
|
||||||
var DefaultConfig = Config{
|
func DefaultConfig() Config {
|
||||||
Database: &DatabaseConfig{
|
return Config{
|
||||||
CacheSize: 16384,
|
Database: &DatabaseConfig{
|
||||||
},
|
CacheSize: 16384,
|
||||||
Updater: &UpdaterConfig{
|
},
|
||||||
Interval: 1 * time.Hour,
|
Updater: &UpdaterConfig{
|
||||||
},
|
Interval: 1 * time.Hour,
|
||||||
API: &APIConfig{
|
},
|
||||||
Port: 6060,
|
API: &APIConfig{
|
||||||
HealthPort: 6061,
|
Port: 6060,
|
||||||
Timeout: 900 * time.Second,
|
HealthPort: 6061,
|
||||||
},
|
Timeout: 900 * time.Second,
|
||||||
Notifier: &NotifierConfig{
|
},
|
||||||
Attempts: 5,
|
Notifier: &NotifierConfig{
|
||||||
RenotifyInterval: 2 * time.Hour,
|
Attempts: 5,
|
||||||
},
|
RenotifyInterval: 2 * time.Hour,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load is a shortcut to open a file, read it, and generate a Config.
|
// Load is a shortcut to open a file, read it, and generate a Config.
|
||||||
// It supports relative and absolute paths. Given "", it returns DefaultConfig.
|
// It supports relative and absolute paths. Given "", it returns DefaultConfig.
|
||||||
func Load(path string) (config *Config, err error) {
|
func Load(path string) (config *Config, err error) {
|
||||||
config = &DefaultConfig
|
var cfgFile File
|
||||||
|
cfgFile.Clair = DefaultConfig()
|
||||||
if path == "" {
|
if path == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -103,7 +106,6 @@ func Load(path string) (config *Config, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var cfgFile File
|
|
||||||
err = yaml.Unmarshal(d, &cfgFile)
|
err = yaml.Unmarshal(d, &cfgFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user