Skip to content

Commit

Permalink
Fix redis_sentinel configuration reading
Browse files Browse the repository at this point in the history
This fix solves two issues:
* The log messages were incorrectly using `redis-sentinel` instead of `redis_sentinel` when dumping the configuration in the logs, which was misleading.
* The configuration entries were not provided default values, preventing Viper from reading the associated environment variables
  • Loading branch information
sebmil-daily committed Sep 3, 2024
1 parent 9bca40c commit 5e08d83
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 5 additions & 5 deletions config/backends.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ type RedisSentinel struct {
}

func (cfg *RedisSentinel) validateAndLog() error {
log.Infof("config.backend.redis-sentinel.sentinel_addrs: %s", cfg.SentinelAddrs)
log.Infof("config.backend.redis-sentinel.master_name: %s", cfg.MasterName)
log.Infof("config.backend.redis-sentinel.db: %d", cfg.Db)
log.Infof("config.backend.redis-sentinel.tls.enabled: %t", cfg.TLS.Enabled)
log.Infof("config.backend.redis-sentinel.tls.insecure_skip_verify: %t", cfg.TLS.InsecureSkipVerify)
log.Infof("config.backend.redis_sentinel.sentinel_addrs: %s", cfg.SentinelAddrs)
log.Infof("config.backend.redis_sentinel.master_name: %s", cfg.MasterName)
log.Infof("config.backend.redis_sentinel.db: %d", cfg.Db)
log.Infof("config.backend.redis_sentinel.tls.enabled: %t", cfg.TLS.Enabled)
log.Infof("config.backend.redis_sentinel.tls.insecure_skip_verify: %t", cfg.TLS.InsecureSkipVerify)
return nil
}

Expand Down
10 changes: 10 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ func setConfigDefaults(v *viper.Viper) {
v.SetDefault("backend.redis.expiration", utils.REDIS_DEFAULT_EXPIRATION_MINUTES)
v.SetDefault("backend.redis.tls.enabled", false)
v.SetDefault("backend.redis.tls.insecure_skip_verify", false)
v.SetDefault("backend.redis.tls.enabled", false)
v.SetDefault("backend.redis.tls.insecure_skip_verify", false)
v.SetDefault("backend.redis_sentinel.db", 0)
v.SetDefault("backend.redis_sentinel.master_name", "")
v.SetDefault("backend.redis_sentinel.password", "")
v.SetDefault("backend.redis_sentinel.sentinel_addrs", []string{})
v.SetDefault("backend.redis_sentinel.tls.enabled", false)
v.SetDefault("backend.redis_sentinel.tls.enabled", false)
v.SetDefault("backend.redis_sentinel.tls.insecure_skip_verify", false)
v.SetDefault("backend.redis_sentinel.tls.insecure_skip_verify", false)
v.SetDefault("backend.ignite.scheme", "")
v.SetDefault("backend.ignite.host", "")
v.SetDefault("backend.ignite.port", 0)
Expand Down

0 comments on commit 5e08d83

Please sign in to comment.