mirror of https://github.com/go-redis/redis.git
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:
parent
61ed601bde
commit
9b831b0427
12
sentinel.go
12
sentinel.go
|
@ -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,
|
||||
|
||||
|
|
Loading…
Reference in New Issue