2017-03-25 16:09:17 +01:00
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
|
2017-04-04 19:28:46 +02:00
|
|
|
"github.com/BurntSushi/toml"
|
2017-03-30 16:09:44 +02:00
|
|
|
|
|
|
|
"github.com/genofire/hs_master-kss-monolith/lib/database"
|
2017-03-30 17:02:20 +02:00
|
|
|
"github.com/genofire/hs_master-kss-monolith/lib/log"
|
2017-03-25 16:09:17 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
//Config the config File of this daemon
|
|
|
|
type Config struct {
|
2017-04-07 13:13:37 +02:00
|
|
|
WebserverBind string `toml:"webserver_bind"`
|
|
|
|
Webroot string `toml:"webroot"`
|
|
|
|
Database database.Config `toml:"database"`
|
|
|
|
GoodRelease GoodReleaseConfig `toml:"good_release"`
|
|
|
|
CacheClean CacheWorkerConfig `toml:"cache_clean"`
|
|
|
|
GoodAvailablityTemplate string `toml:"good_availablity_template"`
|
|
|
|
MicroserviceDependencies struct {
|
|
|
|
Product string `toml:"product"`
|
|
|
|
Permission string `toml:"permission"`
|
|
|
|
} `toml:"microservice_dependencies"`
|
2017-03-25 16:09:17 +01:00
|
|
|
}
|
|
|
|
|
2017-04-07 11:56:28 +02:00
|
|
|
type CacheWorkerConfig struct {
|
|
|
|
Every Duration
|
|
|
|
After Duration
|
|
|
|
}
|
|
|
|
|
|
|
|
type GoodReleaseConfig struct {
|
|
|
|
After Duration `toml:"after"`
|
|
|
|
Every Duration `toml:"every"`
|
|
|
|
}
|
|
|
|
|
2017-03-25 16:09:17 +01:00
|
|
|
// ReadConfigFile reads a config model from path of a yml file
|
|
|
|
func ReadConfigFile(path string) *Config {
|
|
|
|
config := &Config{}
|
|
|
|
file, err := ioutil.ReadFile(path)
|
|
|
|
if err != nil {
|
2017-03-30 16:09:44 +02:00
|
|
|
log.Log.Panic(err)
|
2017-03-25 16:09:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if err := toml.Unmarshal(file, config); err != nil {
|
2017-03-30 16:09:44 +02:00
|
|
|
log.Log.Panic(err)
|
2017-03-25 16:09:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return config
|
|
|
|
}
|