Properly pass username/password in Sentinel (#1452)

* Properly pass username/password in Sentinel

Signed-off-by: Dmitry Shmulevich <dmitry.shmulevich@sysdig.com>
This commit is contained in:
Dmitry Shmulevich 2020-08-26 22:51:57 -07:00 committed by GitHub
parent 61ed601bde
commit 9b831b0427
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 12 deletions

View File

@ -21,8 +21,8 @@ type FailoverOptions struct {
// The master name. // The master name.
MasterName string MasterName string
// A seed list of host:port addresses of sentinel nodes. // A seed list of host:port addresses of sentinel nodes.
SentinelAddrs []string SentinelAddrs []string
SentinelUsername string // Sentinel password from "requirepass <password>" (if enabled) in Sentinel configuration
SentinelPassword string SentinelPassword string
// Following options are copied from Options struct. // Following options are copied from Options struct.
@ -90,10 +90,9 @@ func NewFailoverClient(failoverOpt *FailoverOptions) *Client {
opt.init() opt.init()
failover := &sentinelFailover{ failover := &sentinelFailover{
masterName: failoverOpt.MasterName, masterName: failoverOpt.MasterName,
sentinelAddrs: failoverOpt.SentinelAddrs, sentinelAddrs: failoverOpt.SentinelAddrs,
username: failoverOpt.SentinelUsername, sentinelPassword: failoverOpt.SentinelPassword,
password: failoverOpt.SentinelPassword,
opt: opt, opt: opt,
} }
@ -279,11 +278,10 @@ func (c *SentinelClient) Remove(ctx context.Context, name string) *StringCmd {
} }
type sentinelFailover struct { type sentinelFailover struct {
sentinelAddrs []string sentinelAddrs []string
sentinelPassword string
opt *Options opt *Options
username string
password string
pool *pool.ConnPool pool *pool.ConnPool
poolOnce sync.Once poolOnce sync.Once
@ -374,8 +372,8 @@ func (c *sentinelFailover) masterAddr(ctx context.Context) (string, error) {
Addr: sentinelAddr, Addr: sentinelAddr,
Dialer: c.opt.Dialer, Dialer: c.opt.Dialer,
Username: c.username, Username: c.opt.Username,
Password: c.password, Password: c.opt.Password,
MaxRetries: c.opt.MaxRetries, MaxRetries: c.opt.MaxRetries,