mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-12 07:40:48 -08:00
Parse redis backend url (#804)
As suggested by the go-redis client, parse the url to get the config. This will fix problems, when the url contains a username and/or password. Fixes #798 Signed-off-by: Christian Zunker <christian.zunker@codecentric.cloud>
This commit is contained in:
@@ -32,9 +32,11 @@ type Cache struct {
|
|||||||
func NewCache(backend string) (Cache, error) {
|
func NewCache(backend string) (Cache, error) {
|
||||||
if strings.HasPrefix(backend, "redis://") {
|
if strings.HasPrefix(backend, "redis://") {
|
||||||
log.Logger.Infof("Redis cache: %s", backend)
|
log.Logger.Infof("Redis cache: %s", backend)
|
||||||
redisCache := cache.NewRedisCache(&redis.Options{
|
options, err := redis.ParseURL(backend)
|
||||||
Addr: strings.TrimPrefix(backend, "redis://"),
|
if err != nil {
|
||||||
})
|
return Cache{}, err
|
||||||
|
}
|
||||||
|
redisCache := cache.NewRedisCache(options)
|
||||||
return Cache{Cache: redisCache}, nil
|
return Cache{Cache: redisCache}, nil
|
||||||
}
|
}
|
||||||
fsCache, err := cache.NewFSCache(utils.CacheDir())
|
fsCache, err := cache.NewFSCache(utils.CacheDir())
|
||||||
|
|||||||
Reference in New Issue
Block a user