mirror of
https://github.com/project-zot/zot.git
synced 2024-12-16 21:56:37 -05:00
f618b1d4ef
* ci(deps): upgrade golangci-lint
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
* build(deps): removed disabled linters
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
* build(deps): go run github.com/daixiang0/gci@latest write .
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* build(deps): go run golang.org/x/tools/cmd/goimports@latest -l -w .
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* build(deps): go run github.com/bombsimon/wsl/v4/cmd...@latest -strict-append -test=true -fix ./...
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* build(deps): go run github.com/catenacyber/perfsprint@latest -fix ./...
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* build(deps): replace gomnd by mnd
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* build(deps): make gqlgen
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* build: Revert "build(deps): go run github.com/daixiang0/gci@latest write ."
This reverts commit 5bf8c42e1f
.
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* build(deps): go run github.com/daixiang0/gci@latest write -s 'standard' -s default -s 'prefix(zotregistry.dev/zot)' .
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* build(deps): make gqlgen
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: check-log issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: gci issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: tests
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
---------
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
72 lines
1.8 KiB
Go
72 lines
1.8 KiB
Go
package storage
|
|
|
|
import (
|
|
zerr "zotregistry.dev/zot/errors"
|
|
"zotregistry.dev/zot/pkg/api/config"
|
|
zlog "zotregistry.dev/zot/pkg/log"
|
|
"zotregistry.dev/zot/pkg/storage/cache"
|
|
"zotregistry.dev/zot/pkg/storage/constants"
|
|
)
|
|
|
|
func CreateCacheDatabaseDriver(storageConfig config.StorageConfig, log zlog.Logger) (cache.Cache, error) {
|
|
if !storageConfig.Dedupe && storageConfig.StorageDriver == nil {
|
|
return nil, nil //nolint:nilnil
|
|
}
|
|
|
|
// local cache
|
|
if !storageConfig.RemoteCache {
|
|
params := cache.BoltDBDriverParameters{}
|
|
params.RootDir = storageConfig.RootDirectory
|
|
params.Name = constants.BoltdbName
|
|
params.UseRelPaths = getUseRelPaths(&storageConfig)
|
|
|
|
return Create("boltdb", params, log)
|
|
}
|
|
|
|
// remote cache
|
|
if storageConfig.CacheDriver != nil {
|
|
name, ok := storageConfig.CacheDriver["name"].(string)
|
|
if !ok {
|
|
log.Warn().Msg("remote cache driver name missing!")
|
|
|
|
return nil, nil //nolint:nilnil
|
|
}
|
|
|
|
if name != constants.DynamoDBDriverName {
|
|
log.Warn().Str("driver", name).Msg("remote cache driver unsupported!")
|
|
|
|
return nil, nil //nolint:nilnil
|
|
}
|
|
|
|
// dynamodb
|
|
dynamoParams := cache.DynamoDBDriverParameters{}
|
|
dynamoParams.Endpoint, _ = storageConfig.CacheDriver["endpoint"].(string)
|
|
dynamoParams.Region, _ = storageConfig.CacheDriver["region"].(string)
|
|
dynamoParams.TableName, _ = storageConfig.CacheDriver["cachetablename"].(string)
|
|
|
|
return Create("dynamodb", dynamoParams, log)
|
|
}
|
|
|
|
return nil, nil //nolint:nilnil
|
|
}
|
|
|
|
func Create(dbtype string, parameters interface{}, log zlog.Logger) (cache.Cache, error) {
|
|
switch dbtype {
|
|
case "boltdb":
|
|
{
|
|
return cache.NewBoltDBCache(parameters, log)
|
|
}
|
|
case "dynamodb":
|
|
{
|
|
return cache.NewDynamoDBCache(parameters, log)
|
|
}
|
|
default:
|
|
{
|
|
return nil, zerr.ErrBadConfig
|
|
}
|
|
}
|
|
}
|
|
|
|
func getUseRelPaths(storageConfig *config.StorageConfig) bool {
|
|
return storageConfig.StorageDriver == nil
|
|
}
|