| 1 | module config |
| 2 | |
| 3 | import os |
| 4 | import x.json2 as json |
| 5 | |
| 6 | pub struct Config { |
| 7 | pub: |
| 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 | |
| 18 | pub struct PgConfig { |
| 19 | pub: |
| 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 | |
| 28 | pub struct SqliteConfig { |
| 29 | pub: |
| 30 | path string = 'gitly.sqlite' |
| 31 | } |
| 32 | |
| 33 | pub fn read_config(path string) !Config { |
| 34 | config_raw := os.read_file(path)! |
| 35 | |
| 36 | return json.decode[Config](config_raw)! |
| 37 | } |
| 38 | |