ggdgsdbsdbbb / config / loader.v
37 lines · 31 sloc · 647 bytes · 8f0e771bc9f2b6856d7034474716b39a5e96c171
Raw
1module config
2
3import os
4import 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