From ed2bd33a86f1a21b66cd6099b177c341e597a0a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Millet?= Date: Tue, 3 Sep 2024 14:48:52 +0200 Subject: [PATCH] Fix redis_sentinel configuration reading 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 --- config/backends.go | 10 +++++----- config/config.go | 6 ++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/config/backends.go b/config/backends.go index 122617a6..a29d6a27 100644 --- a/config/backends.go +++ b/config/backends.go @@ -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 } diff --git a/config/config.go b/config/config.go index 59e02080..02bc949f 100644 --- a/config/config.go +++ b/config/config.go @@ -69,6 +69,12 @@ 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_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.insecure_skip_verify", false) v.SetDefault("backend.ignite.scheme", "") v.SetDefault("backend.ignite.host", "") v.SetDefault("backend.ignite.port", 0)