mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-10-14 09:57:16 +00:00
feat: Use databaseBackend config repace databaseEtcd
databaseBackend config contains type and url sub config, It can facilitate the expansion of other types of databases in the future.
This commit is contained in:
1 parent
f29449db14
commit
59bf4501e8
8 files changed
+47
-13
No files matched your search
+10
-2
@@ -3,6 +3,7 @@ package context
|
||||
|
||||
import (
|
||||
gocontext "context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
@@ -289,8 +290,15 @@ func (context *AptlyContext) _database() (database.Storage, error) {
|
||||
if context.database == nil {
|
||||
var err error
|
||||
|
||||
if context.config().DatabaseEtcd != "" {
|
||||
context.database, err = etcddb.NewDB(context.config().DatabaseEtcd)
|
||||
if context.config().DatabaseBackend.Type == "etcd" {
|
||||
context.database, err = etcddb.NewDB(context.config().DatabaseBackend.URL)
|
||||
} else if context.config().DatabaseBackend.Type == "leveldb" {
|
||||
if context.config().DatabaseBackend.DbPath != "" {
|
||||
dbPath := filepath.Join(context.config().RootDir, context.config().DatabaseBackend.DbPath)
|
||||
context.database, err = goleveldb.NewDB(dbPath)
|
||||
} else {
|
||||
return nil, errors.New("leveldb databaseBackend config invalid")
|
||||
}
|
||||
} else {
|
||||
context.database, err = goleveldb.NewDB(context.dbPath())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user