blob: 021fb74f6a88493bc24177780a2e513c5426115f [file] [log] [blame]
iomodo48c837e2021-02-19 01:17:07 +04001package model
2
3const (
4 databaseDriverPostgres = "postgres"
5 defaultDataSource = "postgres://user:test@localhost/pcloud_test?sslmode=disable&connect_timeout=10"
6)
7
8type Config struct {
9 SqlSettings SqlSettings
10}
11
iomodoc6abf5b2021-02-19 14:48:03 +040012func NewConfig() *Config {
13 config := &Config{}
14 config.SetDefaults()
15 return config
16}
17
iomodo48c837e2021-02-19 01:17:07 +040018func (c *Config) SetDefaults() {
19 c.SqlSettings.SetDefaults()
20}
21
22type SqlSettings struct {
23 DriverName string `access:"environment,write_restrictable,cloud_restrictable"`
24 DataSource string `access:"environment,write_restrictable,cloud_restrictable"`
25}
26
27func (s *SqlSettings) SetDefaults() {
28 if s.DriverName == "" {
29 s.DriverName = databaseDriverPostgres
30 }
31
32 if s.DataSource == "" {
33 s.DataSource = defaultDataSource
34 }
35}