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

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