mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
3695aa8140
This is a massive overhaul to the SQL Storage for Authelia. It facilitates a whole heap of utility commands to help manage the database, primary keys, ensures all database requests use a context for cancellations, and paves the way for a few other PR's which improve the database. Fixes #1337
29 lines
888 B
Go
29 lines
888 B
Go
package commands
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/authelia/authelia/v4/internal/storage"
|
|
)
|
|
|
|
func getStorageProvider() (provider storage.Provider, err error) {
|
|
switch {
|
|
case config.Storage.PostgreSQL != nil:
|
|
provider = storage.NewPostgreSQLProvider(*config.Storage.PostgreSQL)
|
|
case config.Storage.MySQL != nil:
|
|
provider = storage.NewMySQLProvider(*config.Storage.MySQL)
|
|
case config.Storage.Local != nil:
|
|
provider = storage.NewSQLiteProvider(config.Storage.Local.Path)
|
|
default:
|
|
return nil, errors.New("no storage provider configured")
|
|
}
|
|
|
|
if (config.Storage.MySQL != nil && config.Storage.PostgreSQL != nil) ||
|
|
(config.Storage.MySQL != nil && config.Storage.Local != nil) ||
|
|
(config.Storage.PostgreSQL != nil && config.Storage.Local != nil) {
|
|
return nil, errors.New("multiple storage providers are configured but should only configure one")
|
|
}
|
|
|
|
return provider, err
|
|
}
|