added more redis config env vars
This commit is contained in:
parent
fb29636608
commit
cf7d30a7f6
2 changed files with 16 additions and 5 deletions
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue