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 }