f-21: config: add config data
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
906201a1b6
commit
cc6c08b522
1 changed files with 12 additions and 0 deletions
|
|
@ -8,6 +8,14 @@ type Config struct {
|
||||||
Database struct {
|
Database struct {
|
||||||
Path string `mapstructure:"path"`
|
Path string `mapstructure:"path"`
|
||||||
} `mapstructure:"database"`
|
} `mapstructure:"database"`
|
||||||
|
Api struct {
|
||||||
|
Address string `mapstructure:"address"`
|
||||||
|
Port int `mapstructure:"port"`
|
||||||
|
} `mapstructure:"api"`
|
||||||
|
Prometheus struct {
|
||||||
|
Address string `mapstructure:"address"`
|
||||||
|
Port int `mapstructure:"port"`
|
||||||
|
} `mapstructure:"prometheus"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadConfig(path string) (*Config, error) {
|
func LoadConfig(path string) (*Config, error) {
|
||||||
|
|
@ -16,6 +24,10 @@ func LoadConfig(path string) (*Config, error) {
|
||||||
v.SetConfigType("yaml")
|
v.SetConfigType("yaml")
|
||||||
|
|
||||||
v.SetDefault("database.path", "/var/lib/two/data/")
|
v.SetDefault("database.path", "/var/lib/two/data/")
|
||||||
|
v.SetDefault("api.address", "")
|
||||||
|
v.SetDefault("api.port", 8080)
|
||||||
|
v.SetDefault("prometheus.address", "")
|
||||||
|
v.SetDefault("prometheus.port", 9090)
|
||||||
|
|
||||||
v.ReadInConfig()
|
v.ReadInConfig()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue