parcoursmob/config.go

224 lines
6.1 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,
},
"members": map[string]any{
"enabled": true,
"profile_optional_fields": []map[string]any{},
},
"beneficiaries": map[string]any{
"enabled": true,
"validated_profile": map[string]any{
"enabled": false,
"required": map[string]any{
"fields": []string{},
"documents": []string{},
},
},
"profile_optional_fields": []map[string]any{
{
"name": "gender",
"label": "Genre",
"type": "select",
"options": []map[string]string{
{"value": "0", "label": "Inconnu"},
{"value": "1", "label": "Masculin"},
{"value": "2", "label": "Féminin"},
{"value": "9", "label": "Sans objet"},
},
},
{
"name": "social_situation",
"label": "Situation sociale",
"type": "select",
"options": []map[string]string{
{"value": "", "label": "Inconnu"},
{"value": "BRSA", "label": "BRSA"},
{"value": "Demandeur d'emploi", "label": "Demandeur d'emploi"},
{"value": "Chantier d'insertion", "label": "Chantier d'insertion"},
{"value": "Jeune -25", "label": "Jeune -25"},
},
},
{
"name": "registration_reason",
"label": "Motif d'inscription",
"type": "select",
"options": []map[string]string{
{"value": "", "label": "Inconnu"},
{"value": "Pas de permis", "label": "Pas de permis"},
{"value": "Pas de véhicule", "label": "Pas de véhicule"},
{"value": "Perte d'autonomie", "label": "Perte d'autonomie"},
{"value": "Autre", "label": "Autre"},
},
},
{
"name": "status",
"label": "Statut (prioritaire / non prioritaire)",
"type": "select",
"options": []map[string]string{
{"value": "Non prioritaire", "label": "Non prioritaire"},
{"value": "Prioritaire", "label": "Prioritaire"},
},
},
{
"name": "last_subscription_date",
"label": "Date de dernière adhésion",
"type": "date",
},
{
"name": "previous_solidarity_transports_count",
"label": "Nombre de transports solidaires précédents",
"type": "number",
},
{
"name": "comment",
"label": "Commentaire",
"type": "textarea",
},
},
},
"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{},
},
},
"profile_optional_fields": []map[string]any{
{
"name": "gender",
"label": "Genre",
"type": "select",
"options": []map[string]string{
{"value": "0", "label": "Inconnu"},
{"value": "1", "label": "Masculin"},
{"value": "2", "label": "Féminin"},
{"value": "9", "label": "Sans objet"},
},
},
{
"name": "last_subscription_date",
"label": "Date de dernière adhésion",
"type": "date",
},
{
"name": "comment",
"label": "Commentaire",
"type": "textarea",
},
},
},
},
"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": true,
"required": map[string]any{
"fields": []string{},
"documents": []string{"driving_licence"},
},
},
},
},
"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
}