Fix getRedisOptionsFromFlags helper

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

12
main.go
View File

@ -103,20 +103,18 @@ func getRedisOptionsFromFlags() (*redis.Options, error) {
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 flagRedisInsecureTLS {
tls.InsecureSkipVerify = true if opts.TLSConfig == nil {
opts.TLSConfig = &tls.Config{}
} }
opts.TLSConfig.InsecureSkipVerify = true
} }
return opts, nil return opts, nil
} }