From 75ad4cefe622a3323e80127fa54da9f36c37d41a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sun, 21 Jul 2024 15:25:49 +0200 Subject: [PATCH] fix PluginSettings. --- server/pkg/types/plugins.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/pkg/types/plugins.go b/server/pkg/types/plugins.go index c0f271f8..c94131ef 100644 --- a/server/pkg/types/plugins.go +++ b/server/pkg/types/plugins.go @@ -75,6 +75,7 @@ func (p PluginSettings) Unmarshal(name string, def any) error { if p == nil { return fmt.Errorf("%w: %s", ErrPluginSettingsNotFound, name) } + // loop through the plugin settings and take only the one that starts with the name // because the settings are stored in a map["plugin_name.setting_name"] = value newMap := make(map[string]any) @@ -83,9 +84,10 @@ func (p PluginSettings) Unmarshal(name string, def any) error { newMap[strings.TrimPrefix(k, name+".")] = v } } - fmt.Printf("newMap: %+v\n", newMap) + if len(newMap) == 0 { return fmt.Errorf("%w: %s", ErrPluginSettingsNotFound, name) } + return utils.Decode(newMap, def) }