gitlyx / config / loader.v
42 lines · 36 sloc · 909 bytes · 31b1cb297e0cd7893d102dbf7410a58b89a2cf54
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 usdt_wallet string
14 // ci_secret is the shared secret used to authenticate CI status callbacks
15 // from gitly_ci (HMAC-SHA256 over the request body). Must match gitly_ci's
16 // ci_secret. When empty, callbacks are accepted unauthenticated (insecure).
17 ci_secret string
18 port int
19 pg PgConfig
20 sqlite SqliteConfig
21}
22
23pub struct PgConfig {
24pub:
25 host string = 'localhost'
26 port int = 5432
27 dbname string = 'gitly'
28 user string = 'gitly'
29 password string = 'gitly'
30 conninfo string
31}
32
33pub struct SqliteConfig {
34pub:
35 path string = 'gitly.sqlite'
36}
37
38pub fn read_config(path string) !Config {
39 config_raw := os.read_file(path)!
40
41 return json.decode[Config](config_raw)!
42}
43