From cf7d30a7f6d63f461fc7637c2b6c0c35fb5053e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Ga=C4=87e=C5=A1a?= Date: Wed, 11 Aug 2021 16:25:50 +0200 Subject: [PATCH] added more redis config env vars --- cmd/drone-server/config/config.go | 3 +++ service/redisdb/redisdb.go | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/cmd/drone-server/config/config.go b/cmd/drone-server/config/config.go index 29b7eae0..94f52ad4 100644 --- a/cmd/drone-server/config/config.go +++ b/cmd/drone-server/config/config.go @@ -170,6 +170,9 @@ type ( // Redis provides the redis configuration. Redis struct { ConnectionString string `envconfig:"DRONE_REDIS_CONNECTION"` + Addr string `envconfig:"DRONE_REDIS_ADDR"` + Password string `envconfig:"DRONE_REDIS_PASSWORD"` + DB int `envconfig:"DRONE_REDIS_DB"` } // Repository provides the repository configuration. diff --git a/service/redisdb/redisdb.go b/service/redisdb/redisdb.go index f604229c..7024cb67 100644 --- a/service/redisdb/redisdb.go +++ b/service/redisdb/redisdb.go @@ -26,12 +26,20 @@ import ( ) func New(config config.Config) (srv RedisDB, err error) { - if config.Redis.ConnectionString == "" { - return - } + var options *redis.Options - options, err := redis.ParseURL(config.Redis.ConnectionString) - if err != nil { + if config.Redis.ConnectionString != "" { + options, err = redis.ParseURL(config.Redis.ConnectionString) + if err != nil { + return + } + } else if config.Redis.Addr != "" { + options = &redis.Options{ + Addr: config.Redis.Addr, + Password: config.Redis.Password, + DB: config.Redis.DB, + } + } else { return }