mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-01-19 11:15:53 +08:00
Properly separate Redis and Sentinel password
This commit is contained in:
parent
bda90ac732
commit
5111aa4f21
@ -109,6 +109,8 @@ func makeRedisConnOpt(cfg *Config) (asynq.RedisConnOpt, error) {
|
|||||||
}
|
}
|
||||||
connOpt := res.(asynq.RedisFailoverClientOpt) // safe to type-assert
|
connOpt := res.(asynq.RedisFailoverClientOpt) // safe to type-assert
|
||||||
connOpt.TLSConfig = makeTLSConfig(cfg)
|
connOpt.TLSConfig = makeTLSConfig(cfg)
|
||||||
|
connOpt.SentinelPassword = connOpt.Password // password from asynq.ParseRedisURI should be used for sentinel
|
||||||
|
connOpt.Password = cfg.RedisPassword // override parsed password with value from config
|
||||||
return connOpt, nil
|
return connOpt, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,13 +100,27 @@ func TestMakeRedisConnOpt(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "With redis-sentinel URL",
|
desc: "With redis-sentinel URL",
|
||||||
cfg: &Config{
|
cfg: &Config{
|
||||||
RedisURL: "redis-sentinel://:secretpassword@localhost:5000,localhost:5001,localhost:5002?master=mymaster",
|
RedisURL: "redis-sentinel://:sentinelpassword@localhost:5000,localhost:5001,localhost:5002?master=mymaster",
|
||||||
},
|
},
|
||||||
want: asynq.RedisFailoverClientOpt{
|
want: asynq.RedisFailoverClientOpt{
|
||||||
MasterName: "mymaster",
|
MasterName: "mymaster",
|
||||||
SentinelAddrs: []string{
|
SentinelAddrs: []string{
|
||||||
"localhost:5000", "localhost:5001", "localhost:5002"},
|
"localhost:5000", "localhost:5001", "localhost:5002"},
|
||||||
Password: "secretpassword", // FIXME: Shouldn't this be SentinelPassword instead?
|
SentinelPassword: "sentinelpassword",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "With redis-sentinel URL and password",
|
||||||
|
cfg: &Config{
|
||||||
|
RedisURL: "redis-sentinel://:sentinelpassword@localhost:5000,localhost:5001,localhost:5002?master=mymaster",
|
||||||
|
RedisPassword: "redispassword",
|
||||||
|
},
|
||||||
|
want: asynq.RedisFailoverClientOpt{
|
||||||
|
MasterName: "mymaster",
|
||||||
|
SentinelAddrs: []string{
|
||||||
|
"localhost:5000", "localhost:5001", "localhost:5002"},
|
||||||
|
SentinelPassword: "sentinelpassword",
|
||||||
|
Password: "redispassword",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user