f-21: config: add config data

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-04-12 17:30:58 +02:00
commit 1bb3681b68
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632

View file

@ -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()