| iomodo | 48c837e | 2021-02-19 01:17:07 +0400 | [diff] [blame^] | 1 | package model |
| 2 | |
| 3 | const ( |
| 4 | databaseDriverPostgres = "postgres" |
| 5 | defaultDataSource = "postgres://user:test@localhost/pcloud_test?sslmode=disable&connect_timeout=10" |
| 6 | ) |
| 7 | |
| 8 | type Config struct { |
| 9 | SqlSettings SqlSettings |
| 10 | } |
| 11 | |
| 12 | func (c *Config) SetDefaults() { |
| 13 | c.SqlSettings.SetDefaults() |
| 14 | } |
| 15 | |
| 16 | type SqlSettings struct { |
| 17 | DriverName string `access:"environment,write_restrictable,cloud_restrictable"` |
| 18 | DataSource string `access:"environment,write_restrictable,cloud_restrictable"` |
| 19 | } |
| 20 | |
| 21 | func (s *SqlSettings) SetDefaults() { |
| 22 | if s.DriverName == "" { |
| 23 | s.DriverName = databaseDriverPostgres |
| 24 | } |
| 25 | |
| 26 | if s.DataSource == "" { |
| 27 | s.DataSource = defaultDataSource |
| 28 | } |
| 29 | } |