From a41accd033a8d7e859a4bff89ae64e1f3500e4d2 Mon Sep 17 00:00:00 2001 From: Qais Patankar Date: Wed, 24 Jun 2020 23:25:10 +0100 Subject: Add sane RemoteNickFormat default for API (#1157) --- bridge/config/config.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'bridge/config/config.go') diff --git a/bridge/config/config.go b/bridge/config/config.go index 59d7d4be..d98c9423 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -219,6 +219,7 @@ type BridgeValues struct { type Config interface { Viper() *viper.Viper BridgeValues() *BridgeValues + IsKeySet(key string) bool GetBool(key string) (bool, bool) GetInt(key string) (int, bool) GetString(key string) (string, bool) @@ -303,6 +304,12 @@ func (c *config) Viper() *viper.Viper { return c.v } +func (c *config) IsKeySet(key string) bool { + c.RLock() + defer c.RUnlock() + return c.v.IsSet(key) +} + func (c *config) GetBool(key string) (bool, bool) { c.RLock() defer c.RUnlock() @@ -362,6 +369,11 @@ type TestConfig struct { Overrides map[string]interface{} } +func (c *TestConfig) IsKeySet(key string) bool { + _, ok := c.Overrides[key] + return ok || c.Config.IsKeySet(key) +} + func (c *TestConfig) GetBool(key string) (bool, bool) { val, ok := c.Overrides[key] if ok { -- cgit v1.2.3