2019-04-24 21:52:08 +00:00
|
|
|
package schema
|
|
|
|
|
2022-10-22 08:27:59 +00:00
|
|
|
import (
|
|
|
|
"crypto/tls"
|
2023-05-07 06:39:17 +00:00
|
|
|
"net/url"
|
2022-10-22 08:27:59 +00:00
|
|
|
"time"
|
|
|
|
)
|
2021-08-06 05:35:14 +00:00
|
|
|
|
2019-04-24 21:52:08 +00:00
|
|
|
// LocalStorageConfiguration represents the configuration when using local storage.
|
|
|
|
type LocalStorageConfiguration struct {
|
2021-08-03 09:55:21 +00:00
|
|
|
Path string `koanf:"path"`
|
2019-04-24 21:52:08 +00:00
|
|
|
}
|
|
|
|
|
2020-05-02 05:06:39 +00:00
|
|
|
// SQLStorageConfiguration represents the configuration of the SQL database.
|
2019-11-16 10:38:21 +00:00
|
|
|
type SQLStorageConfiguration struct {
|
2023-05-07 06:39:17 +00:00
|
|
|
Address *AddressTCP `koanf:"address"`
|
2021-08-06 05:35:14 +00:00
|
|
|
Database string `koanf:"database"`
|
|
|
|
Username string `koanf:"username"`
|
|
|
|
Password string `koanf:"password"`
|
|
|
|
Timeout time.Duration `koanf:"timeout"`
|
2023-05-07 06:39:17 +00:00
|
|
|
|
|
|
|
// Deprecated: use address instead.
|
|
|
|
Host string `koanf:"host"`
|
|
|
|
|
|
|
|
// Deprecated: use address instead.
|
|
|
|
Port int `koanf:"port"`
|
2019-11-16 10:38:21 +00:00
|
|
|
}
|
|
|
|
|
2020-05-02 05:06:39 +00:00
|
|
|
// MySQLStorageConfiguration represents the configuration of a MySQL database.
|
2019-11-16 19:50:58 +00:00
|
|
|
type MySQLStorageConfiguration struct {
|
2021-08-03 09:55:21 +00:00
|
|
|
SQLStorageConfiguration `koanf:",squash"`
|
2022-10-22 08:27:59 +00:00
|
|
|
|
|
|
|
TLS *TLSConfig `koanf:"tls"`
|
2019-11-16 19:50:58 +00:00
|
|
|
}
|
|
|
|
|
2021-12-02 05:36:03 +00:00
|
|
|
// PostgreSQLStorageConfiguration represents the configuration of a PostgreSQL database.
|
2019-11-16 19:50:58 +00:00
|
|
|
type PostgreSQLStorageConfiguration struct {
|
2021-08-03 09:55:21 +00:00
|
|
|
SQLStorageConfiguration `koanf:",squash"`
|
2021-12-02 05:36:03 +00:00
|
|
|
Schema string `koanf:"schema"`
|
|
|
|
|
2022-10-22 08:27:59 +00:00
|
|
|
TLS *TLSConfig `koanf:"tls"`
|
|
|
|
|
|
|
|
SSL *PostgreSQLSSLStorageConfiguration `koanf:"ssl"`
|
2021-12-02 05:36:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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-16 19:50:58 +00:00
|
|
|
}
|
|
|
|
|
2019-04-24 21:52:08 +00:00
|
|
|
// StorageConfiguration represents the configuration of the storage backend.
|
|
|
|
type StorageConfiguration struct {
|
2021-08-03 09:55:21 +00:00
|
|
|
Local *LocalStorageConfiguration `koanf:"local"`
|
|
|
|
MySQL *MySQLStorageConfiguration `koanf:"mysql"`
|
|
|
|
PostgreSQL *PostgreSQLStorageConfiguration `koanf:"postgres"`
|
2021-11-25 01:56:58 +00:00
|
|
|
|
|
|
|
EncryptionKey string `koanf:"encryption_key"`
|
2019-04-24 21:52:08 +00:00
|
|
|
}
|
2021-08-06 05:35:14 +00:00
|
|
|
|
2021-12-02 05:36:03 +00:00
|
|
|
// DefaultSQLStorageConfiguration represents the default SQL configuration.
|
|
|
|
var DefaultSQLStorageConfiguration = SQLStorageConfiguration{
|
|
|
|
Timeout: 5 * time.Second,
|
2021-08-06 05:35:14 +00:00
|
|
|
}
|
2021-12-03 06:29:55 +00:00
|
|
|
|
2022-10-22 08:27:59 +00:00
|
|
|
// DefaultMySQLStorageConfiguration represents the default MySQL configuration.
|
|
|
|
var DefaultMySQLStorageConfiguration = MySQLStorageConfiguration{
|
|
|
|
TLS: &TLSConfig{
|
|
|
|
MinimumVersion: TLSVersion{tls.VersionTLS12},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-12-03 06:29:55 +00:00
|
|
|
// DefaultPostgreSQLStorageConfiguration represents the default PostgreSQL configuration.
|
|
|
|
var DefaultPostgreSQLStorageConfiguration = PostgreSQLStorageConfiguration{
|
2023-05-07 06:39:17 +00:00
|
|
|
SQLStorageConfiguration: SQLStorageConfiguration{
|
|
|
|
Address: &AddressTCP{Address{true, false, 5432, &url.URL{Scheme: AddressSchemeTCP, Host: "localhost:5432"}}},
|
|
|
|
},
|
2021-12-03 06:29:55 +00:00
|
|
|
Schema: "public",
|
2022-10-22 08:27:59 +00:00
|
|
|
TLS: &TLSConfig{
|
|
|
|
MinimumVersion: TLSVersion{tls.VersionTLS12},
|
|
|
|
},
|
|
|
|
SSL: &PostgreSQLSSLStorageConfiguration{
|
2021-12-03 06:29:55 +00:00
|
|
|
Mode: "disable",
|
|
|
|
},
|
|
|
|
}
|