aboutsummaryrefslogtreecommitdiff
path: root/pkg/config
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkg/config/yaml.go9
-rw-r--r--pkg/config/yaml_test.go2
2 files changed, 11 insertions, 0 deletions
diff --git a/pkg/config/yaml.go b/pkg/config/yaml.go
index 9711130..f6b9edd 100644
--- a/pkg/config/yaml.go
+++ b/pkg/config/yaml.go
@@ -1,6 +1,7 @@
package config
import (
+ "errors"
"fmt"
"io"
"reflect"
@@ -67,6 +68,7 @@ func unmarshal(in io.Reader, cfg *Config) (config, error) {
parsedCfg := config{Config: cfg}
d := yaml.NewDecoder(in)
+ d.KnownFields(true)
if err := d.Decode(&parsedCfg); err != nil && err != io.EOF {
return config{}, err
}
@@ -81,6 +83,13 @@ func (cfg *Config) parse(in io.Reader) error {
)
if parsedCfg, err = unmarshal(in, cfg); err != nil {
+ var typeError *yaml.TypeError
+ if errors.As(err, &typeError) {
+ const sep = "\n\t"
+ errMsgs := strings.Join(typeError.Errors, sep)
+ return fmt.Errorf("config is invalid: %s%s", sep, errMsgs)
+ }
+
return fmt.Errorf("while unmarshalling: %w", err)
}
diff --git a/pkg/config/yaml_test.go b/pkg/config/yaml_test.go
index 4fc501a..ded9453 100644
--- a/pkg/config/yaml_test.go
+++ b/pkg/config/yaml_test.go
@@ -212,6 +212,8 @@ func TestUnmarshal(tst *testing.T) {
c.FeedOptions.MinFreq = 6
return c
}()},
+ {name: "Known config with invalid feed-options",
+ inp: "options:\n max-frequency: 6", wantErr: true, config: config{}},
{name: "Config with feed",
inp: `
something: 1
' Neumann3-95/+126 2008-07-04Fixed find_best_match for <portage-2.1.5René 'Necoro' Neumann1-2/+2 2008-07-04Some more dependency awarenessRené 'Necoro' Neumann5-23/+59 2008-07-03Some window refinementRené 'Necoro' Neumann1-109/+126 2008-07-03Removed XSD_LOCATION -- as there is no more xsd ;)René 'Necoro' Neumann2-5/+1 2008-07-03Updated setup.py to install the correct set of pluginsRené 'Necoro' Neumann1-3/+2 2008-07-03Ported etc-proposals pluginRené 'Necoro' Neumann3-50/+43 2008-07-03Ported gpytage pluginRené 'Necoro' Neumann2-16/+14 2008-07-03Ported Notify pluginRené 'Necoro' Neumann4-37/+51 2008-07-03Remove xsd and -x cmdline optionRené 'Necoro' Neumann2-107/+1 2008-07-03Ported completelyRené 'Necoro' Neumann3-548/+54 2008-07-03Should show dependencies nowRené 'Necoro' Neumann2-82/+128 2008-07-03Use __slots__ for the PkgData class to save memoryRené 'Necoro' Neumann1-2/+3 2008-07-03New plugin system - first hackRené 'Necoro' Neumann2-420/+683 2008-06-30Now the new design is able to do the same as the old oneRené 'Necoro' Neumann3-168/+182 2008-06-30First draft of the new plugin windowRené 'Necoro' Neumann1-8/+172 2008-06-30Added stuff to plugin.pyRené 'Necoro' Neumann1-2/+24 2008-06-30Only add a package to mergequeue if everything went fineRené 'Necoro' Neumann1-1/+1 2008-06-25Now load 22 versions when running the correct portageRené 'Necoro' Neumann4-8/+18 2008-06-25Added Package_22 and System_22René 'Necoro' Neumann4-5/+63