plz / config / loader.v
37 lines · 31 sloc · 658 bytes · c1be7a1408ed30cff2e8e359cf7e1ef69d66e988
Raw
1module config
2
3import os
4import x.json2 as json
5
6pub struct Config {
7pub:
8 repo_storage_path string
9 archive_path string
10 avatars_path string
11 hostname string
12 ci_service_url string
13 port int
14 pg PgConfig
15 sqlite SqliteConfig
16}
17
18pub struct PgConfig {
19pub:
20 host string = 'localhost'
21 port int = 5432
22 dbname string = 'gitly'
23 user string = 'gitly'
24 password string = 'gitly'
25 conninfo string
26}
27
28pub struct SqliteConfig {
29pub:
30 path string = 'gitly.sqlite'
31}
32
33pub fn read_config(path string) !Config {
34 config_raw := os.read_file(path)!
35
36 return json.decode[Config](config_raw)!
37}
38