mirror of
https://github.com/project-zot/zot.git
synced 2024-12-16 21:56:37 -05:00
37 lines
910 B
Go
37 lines
910 B
Go
|
package repodbfactory
|
||
|
|
||
|
import (
|
||
|
"zotregistry.io/zot/errors"
|
||
|
"zotregistry.io/zot/pkg/meta/repodb"
|
||
|
boltdb_wrapper "zotregistry.io/zot/pkg/meta/repodb/boltdb-wrapper"
|
||
|
dynamodb_wrapper "zotregistry.io/zot/pkg/meta/repodb/dynamodb-wrapper"
|
||
|
dynamoParams "zotregistry.io/zot/pkg/meta/repodb/dynamodb-wrapper/params"
|
||
|
)
|
||
|
|
||
|
func Create(dbtype string, parameters interface{}) (repodb.RepoDB, error) { //nolint:contextcheck
|
||
|
switch dbtype {
|
||
|
case "boltdb":
|
||
|
{
|
||
|
properParameters, ok := parameters.(boltdb_wrapper.DBParameters)
|
||
|
if !ok {
|
||
|
panic("failed type assertion")
|
||
|
}
|
||
|
|
||
|
return boltdb_wrapper.NewBoltDBWrapper(properParameters)
|
||
|
}
|
||
|
case "dynamodb":
|
||
|
{
|
||
|
properParameters, ok := parameters.(dynamoParams.DBDriverParameters)
|
||
|
if !ok {
|
||
|
panic("failed type assertion")
|
||
|
}
|
||
|
|
||
|
return dynamodb_wrapper.NewDynamoDBWrapper(properParameters)
|
||
|
}
|
||
|
default:
|
||
|
{
|
||
|
return nil, errors.ErrBadConfig
|
||
|
}
|
||
|
}
|
||
|
}
|