39 lines
964 B
Go
39 lines
964 B
Go
package etc
|
|
|
|
import (
|
|
"git.sr.ht/~cco/go-scopes/config"
|
|
sql "git.sr.ht/~cco/go-scopes/storage"
|
|
)
|
|
|
|
func ConfigSqlite() *sql.Cfg {
|
|
ovr := OverridesSql().Use
|
|
return &sql.Cfg{
|
|
Driver: "sqlite",
|
|
Connstr: ovr("somefile.sqlite", SQLITE_CONNSTR),
|
|
}
|
|
}
|
|
|
|
func ConfigPgsql() *sql.Cfg {
|
|
ovr := OverridesSql().Use
|
|
return &sql.Cfg{
|
|
Driver: "postgres",
|
|
Connstr: ovr("user=ccotest password=cco dbname=ccotest", PGSQL_CONNSTR),
|
|
}
|
|
}
|
|
|
|
// collect here the names of fields that may be overridden via
|
|
// explicit Override() or SCOPES_* environment settings.
|
|
const (
|
|
SQLITE_CONNSTR = "sqlite_connstr"
|
|
PGSQL_CONNSTR = "pgsql_connstr"
|
|
)
|
|
|
|
// in a production scenario this should be put in a separate
|
|
// file `settings.go` that should not be stored in code repository.
|
|
func OverridesSql() config.Settings {
|
|
return config.Settings{
|
|
//SQLITE_CONNSTR: ":memory",
|
|
SQLITE_CONNSTR: "data/scopes.sqlite",
|
|
PGSQL_CONNSTR: "user=ccotest password=cco dbname=scpstest",
|
|
}
|
|
}
|