2019-04-25 04:52:08 +07:00
|
|
|
package schema
|
|
|
|
|
2021-08-06 12:35:14 +07:00
|
|
|
import "time"
|
|
|
|
|
2019-04-25 04:52:08 +07:00
|
|
|
// LocalStorageConfiguration represents the configuration when using local storage.
|
|
|
|
type LocalStorageConfiguration struct {
|
2021-08-03 16:55:21 +07:00
|
|
|
Path string `koanf:"path"`
|
2019-04-25 04:52:08 +07:00
|
|
|
}
|
|
|
|
|
2020-05-02 12:06:39 +07:00
|
|
|
// SQLStorageConfiguration represents the configuration of the SQL database.
|
2019-11-16 17:38:21 +07:00
|
|
|
type SQLStorageConfiguration struct {
|
2021-08-06 12:35:14 +07:00
|
|
|
Host string `koanf:"host"`
|
|
|
|
Port int `koanf:"port"`
|
|
|
|
Database string `koanf:"database"`
|
|
|
|
Username string `koanf:"username"`
|
|
|
|
Password string `koanf:"password"`
|
|
|
|
Timeout time.Duration `koanf:"timeout"`
|
2019-11-16 17:38:21 +07:00
|
|
|
}
|
|
|
|
|
2020-05-02 12:06:39 +07:00
|
|
|
// MySQLStorageConfiguration represents the configuration of a MySQL database.
|
2019-11-17 02:50:58 +07:00
|
|
|
type MySQLStorageConfiguration struct {
|
2021-08-03 16:55:21 +07:00
|
|
|
SQLStorageConfiguration `koanf:",squash"`
|
2019-11-17 02:50:58 +07:00
|
|
|
}
|
|
|
|
|
2021-12-02 12:36:03 +07:00
|
|
|
// PostgreSQLStorageConfiguration represents the configuration of a PostgreSQL database.
|
2019-11-17 02:50:58 +07:00
|
|
|
type PostgreSQLStorageConfiguration struct {
|
2021-08-03 16:55:21 +07:00
|
|
|
SQLStorageConfiguration `koanf:",squash"`
|
2021-12-02 12:36:03 +07:00
|
|
|
Schema string `koanf:"schema"`
|
|
|
|
|
|
|
|
SSL PostgreSQLSSLStorageConfiguration `koanf:"ssl"`
|
|
|
|
|
|
|
|
// Deprecated. TODO: Remove in v4.36.0.
|
|
|
|
SSLMode string `koanf:"sslmode"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// PostgreSQLSSLStorageConfiguration represents the SSL configuration of a PostgreSQL database.
|
|
|
|
type PostgreSQLSSLStorageConfiguration struct {
|
|
|
|
Mode string `koanf:"mode"`
|
|
|
|
RootCertificate string `koanf:"root_certificate"`
|
|
|
|
Certificate string `koanf:"certificate"`
|
|
|
|
Key string `koanf:"key"`
|
2019-11-17 02:50:58 +07:00
|
|
|
}
|
|
|
|
|
2019-04-25 04:52:08 +07:00
|
|
|
// StorageConfiguration represents the configuration of the storage backend.
|
|
|
|
type StorageConfiguration struct {
|
2021-08-03 16:55:21 +07:00
|
|
|
Local *LocalStorageConfiguration `koanf:"local"`
|
|
|
|
MySQL *MySQLStorageConfiguration `koanf:"mysql"`
|
|
|
|
PostgreSQL *PostgreSQLStorageConfiguration `koanf:"postgres"`
|
2021-11-25 08:56:58 +07:00
|
|
|
|
|
|
|
EncryptionKey string `koanf:"encryption_key"`
|
2019-04-25 04:52:08 +07:00
|
|
|
}
|
2021-08-06 12:35:14 +07:00
|
|
|
|
2021-12-02 12:36:03 +07:00
|
|
|
// DefaultSQLStorageConfiguration represents the default SQL configuration.
|
|
|
|
var DefaultSQLStorageConfiguration = SQLStorageConfiguration{
|
|
|
|
Timeout: 5 * time.Second,
|
2021-08-06 12:35:14 +07:00
|
|
|
}
|
2021-12-03 13:29:55 +07:00
|
|
|
|
|
|
|
// DefaultPostgreSQLStorageConfiguration represents the default PostgreSQL configuration.
|
|
|
|
var DefaultPostgreSQLStorageConfiguration = PostgreSQLStorageConfiguration{
|
|
|
|
Schema: "public",
|
|
|
|
SSL: PostgreSQLSSLStorageConfiguration{
|
|
|
|
Mode: "disable",
|
|
|
|
},
|
|
|
|
}
|