273 lines
8.0 KiB
Go
Executable File
273 lines
8.0 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", // DEPRECATED
|
|
"web": map[string]any{
|
|
"enabled": true,
|
|
"listen": "0.0.0.0:8080",
|
|
},
|
|
"mcp": map[string]any{
|
|
"enabled": false,
|
|
"listen": "0.0.0.0:8081",
|
|
},
|
|
},
|
|
"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,
|
|
"search_view": "tabs",
|
|
},
|
|
"solidarity_transport": map[string]any{
|
|
"enabled": true,
|
|
"pagination": map[string]any{
|
|
"trips_items_per_page": 10,
|
|
"drivers_items_per_page": 10,
|
|
},
|
|
"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",
|
|
},
|
|
},
|
|
},
|
|
"booking_motivations": []map[string]string{
|
|
{"value": "Administratif", "label": "Administratif (trajet garanti)"},
|
|
{"value": "Commerce", "label": "Commerce"},
|
|
{"value": "Courses", "label": "Courses"},
|
|
{"value": "Insertion", "label": "Insertion (trajet garanti)"},
|
|
{"value": "Loisirs", "label": "Loisirs"},
|
|
{"value": "Visite à un proche", "label": "Visite à un proche"},
|
|
{"value": "Santé", "label": "Santé (trajet garanti)"},
|
|
{"value": "", "label": "Autre "},
|
|
},
|
|
"guaranteed_trip_motivations": []string{"Santé", "Insertion", "Administratif"},
|
|
},
|
|
"organized_carpool": map[string]any{
|
|
"enabled": true,
|
|
"pagination": map[string]any{
|
|
"trips_items_per_page": 10,
|
|
"drivers_items_per_page": 10,
|
|
},
|
|
"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"},
|
|
},
|
|
},
|
|
},
|
|
"booking_motivations": []map[string]string{
|
|
{"value": "Administratif", "label": "Administratif"},
|
|
{"value": "Commerce", "label": "Commerce"},
|
|
{"value": "Courses", "label": "Courses"},
|
|
{"value": "Insertion", "label": "Insertion"},
|
|
{"value": "Loisirs", "label": "Loisirs"},
|
|
{"value": "Travail", "label": "Travail"},
|
|
{"value": "Formation", "label": "Formation"},
|
|
{"value": "Visite à un proche", "label": "Visite à un proche"},
|
|
{"value": "Santé", "label": "Santé"},
|
|
{"value": "", "label": "Autre "},
|
|
},
|
|
},
|
|
"vehicles": map[string]any{
|
|
"enabled": true,
|
|
},
|
|
"vehicles_management": map[string]any{
|
|
"enabled": true,
|
|
},
|
|
"fleets": map[string]any{
|
|
"vehicle_types": []string{"Voiture", "Voiture sans permis", "Scooter", "Trotinette", "Vélo électrique"},
|
|
"vehicle_optional_fields": []map[string]any{},
|
|
},
|
|
"agenda": map[string]any{
|
|
"enabled": true,
|
|
},
|
|
"directory": map[string]any{
|
|
"enabled": true,
|
|
},
|
|
"support": map[string]any{
|
|
"enabled": true,
|
|
"email": "support@mobicoop.fr",
|
|
},
|
|
},
|
|
"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",
|
|
},
|
|
},
|
|
"filters": map[string]any{
|
|
"enabled": false,
|
|
"geographies": []map[string]string{},
|
|
},
|
|
},
|
|
}
|
|
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
|
|
}
|