From e942c1b0b38560cb09afccc81502e3b81c7977bc Mon Sep 17 00:00:00 2001 From: Ken Hibino Date: Sat, 8 May 2021 21:38:52 -0700 Subject: [PATCH] Fix getRedisOptionsFromFlags helper --- main.go | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/main.go b/main.go index cad3cfc..7fe6f2c 100644 --- a/main.go +++ b/main.go @@ -100,23 +100,21 @@ func getRedisOptionsFromFlags() (*redis.Options, error) { } } else { opts = &redis.Options{ - Addr: flagRedisAddr, - DB: flagRedisDB, - Password: flagRedisPassword, - TLSConfig: &tls.Config{}, + Addr: flagRedisAddr, + DB: flagRedisDB, + Password: flagRedisPassword, } } - if tls := opts.TLSConfig; tls != nil { - if tlsHost := flagRedisTLS; tlsHost != "" { - tls.ServerName = tlsHost - } - - if flagRedisInsecureTLS { - tls.InsecureSkipVerify = true - } + if flagRedisTLS != "" { + opts.TLSConfig = &tls.Config{ServerName: flagRedisTLS} + } + if flagRedisInsecureTLS { + if opts.TLSConfig == nil { + opts.TLSConfig = &tls.Config{} + } + opts.TLSConfig.InsecureSkipVerify = true } - return opts, nil }