Fix getRedisOptionsFromFlags helper

This commit is contained in:
Ken Hibino 2021-05-08 21:38:52 -07:00
parent 0eb9d88c53
commit e942c1b0b3

24
main.go
View File

@ -100,23 +100,21 @@ func getRedisOptionsFromFlags() (*redis.Options, error) {
} }
} else { } else {
opts = &redis.Options{ opts = &redis.Options{
Addr: flagRedisAddr, Addr: flagRedisAddr,
DB: flagRedisDB, DB: flagRedisDB,
Password: flagRedisPassword, Password: flagRedisPassword,
TLSConfig: &tls.Config{},
} }
} }
if tls := opts.TLSConfig; tls != nil { if flagRedisTLS != "" {
if tlsHost := flagRedisTLS; tlsHost != "" { opts.TLSConfig = &tls.Config{ServerName: flagRedisTLS}
tls.ServerName = tlsHost }
} if flagRedisInsecureTLS {
if opts.TLSConfig == nil {
if flagRedisInsecureTLS { opts.TLSConfig = &tls.Config{}
tls.InsecureSkipVerify = true }
} opts.TLSConfig.InsecureSkipVerify = true
} }
return opts, nil return opts, nil
} }