parcoursmob/config.go

136 lines
3.4 KiB
Go
Executable File

package main
import (
"strings"
"github.com/spf13/viper"
)
func ReadConfig() (*viper.Viper, error) {
defaults := map[string]any{
"service_name": "PARCOURSMOB",
"templates": map[string]any{
"dir": "templates/default",
"public_dir": "template/default/public",
},
"server": map[string]any{
"listen": "0.0.0.0:9000",
},
"identification": map[string]any{
"sessions": map[string]any{
"store": "cookie",
"session_key": "SESSION_KEY",
},
},
"storage": map[string]any{
"files": map[string]any{
"file_types": map[string]string{
"driving_licence": "Permis de conduire",
"work_contract": "Contrat de travail",
"identity_proof": "Pièce d'identité",
"membership_form": "Bulletin d'adhésion",
"other": "Autre",
},
},
},
"modules": map[string]any{
"dashboard": map[string]any{
"enabled": true,
},
"beneficiaries": map[string]any{
"enabled": true,
"validated_profile": map[string]any{
"enabled": false,
"required": map[string]any{
"fields": []string{},
"documents": []string{},
},
},
},
"journeys": map[string]any{
"enabled": true,
},
"solidarity_transport": map[string]any{
"enabled": true,
"drivers": map[string]any{
"documents_types": []string{"membership_form", "driving_licence", "identity_proof", "other"},
"validated_profile": map[string]any{
"enabled": false,
"required": map[string]any{
"fields": []string{},
"documents": []string{},
},
},
},
},
"organized_carpool": map[string]any{
"enabled": true,
"drivers": map[string]any{
"documents_types": []string{"membership_form", "driving_licence", "identity_proof", "other"},
"validated_profile": map[string]any{
"enabled": false,
"required": map[string]any{
"fields": []string{},
"documents": []string{},
},
},
},
},
"vehicles": map[string]any{
"enabled": true,
},
"vehicles_management": map[string]any{
"enabled": true,
},
"agenda": map[string]any{
"enabled": true,
},
"directory": map[string]any{
"enabled": true,
},
"support": map[string]any{
"enabled": true,
},
},
"geo": map[string]any{
"pelias": map[string]any{
"url": "https://geocode.ridygo.fr",
},
},
"geography": map[string]any{
"storage": map[string]any{
"index": map[string]any{
"type": "memory_rtree",
"bleve": map[string]any{
"file": "index.bleve",
},
},
},
"services": map[string]any{
"grpc": map[string]any{
"enable": true,
"port": 8080,
},
},
"data": map[string]any{
"layers": map[string]string{
"regions": "https://etalab-datasets.geo.data.gouv.fr/contours-administratifs/latest/geojson/regions-50m.geojson",
"departements": "https://etalab-datasets.geo.data.gouv.fr/contours-administratifs/latest/geojson/departements-50m.geojson",
"epci": "https://etalab-datasets.geo.data.gouv.fr/contours-administratifs/latest/geojson/epci-50m.geojson",
"communes": "https://etalab-datasets.geo.data.gouv.fr/contours-administratifs/latest/geojson/communes-50m.geojson",
},
},
},
}
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
}