Files
fleets/config.go
Arnaud Delcasse 6007cffdf1
All checks were successful
Build and Push Docker Image / build_and_push (push) Successful in 5m22s
feat: ajout manual_status et status_history aux réservations
2026-02-26 17:55:10 +01:00

46 lines
861 B
Go

package main
import (
"strings"
"github.com/spf13/viper"
)
func ReadConfig() (*viper.Viper, error) {
defaults := map[string]any{
"name": "COOPGO Fleets",
"dev_env": false,
"storage": map[string]any{
"db": map[string]any{
"type": "mongodb",
"mongodb": map[string]any{
"host": "localhost",
"port": "27017",
"db_name": "coopgo_platform",
"collections": map[string]any{
"vehicles": "vehicles",
"bookings": "bookings",
},
},
},
},
"services": map[string]any{
"grpc": map[string]any{
"enable": true,
"port": 8093,
},
},
}
v := viper.New()
for key, value := range defaults {
v.SetDefault(key, value)
}
v.SetConfigName("config")
v.AddConfigPath(".")
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
v.AutomaticEnv()
err := v.ReadInConfig()
return v, err
}