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) {
|
||||
if strings.HasPrefix(backend, "redis://") {
|
||||
log.Logger.Infof("Redis cache: %s", backend)
|
||||
redisCache := cache.NewRedisCache(&redis.Options{
|
||||
Addr: strings.TrimPrefix(backend, "redis://"),
|
||||
})
|
||||
options, err := redis.ParseURL(backend)
|
||||
if err != nil {
|
||||
return Cache{}, err
|
||||
}
|
||||
redisCache := cache.NewRedisCache(options)
|
||||
return Cache{Cache: redisCache}, nil
|
||||
}
|
||||
fsCache, err := cache.NewFSCache(utils.CacheDir())
|
||||
|
||||
Reference in New Issue
Block a user