fix: need to use viper.Sub to scope on the protocol namespace and unmarshal

This commit is contained in:
Derrick Hammer 2024-02-23 07:54:45 -05:00
parent 6ddd10a4c9
commit daf63268eb
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 4 additions and 2 deletions

View File

@ -58,13 +58,15 @@ func NewManager(logger *zap.Logger) (*Manager, error) {
func (m *Manager) ConfigureProtocol(name string, cfg ProtocolConfig) error {
defaults := cfg.Defaults()
m.setDefaults(defaults, fmt.Sprintf("protocol.%s", name))
protocolPrefix := fmt.Sprintf("protocol.%s", name)
m.setDefaults(defaults, protocolPrefix)
err := m.maybeSave()
if err != nil {
return err
}
return m.viper.Unmarshal(cfg)
return m.viper.Sub(protocolPrefix).Unmarshal(cfg)
}
func (m *Manager) setDefaults(defaults map[string]interface{}, prefix string) {