aboutsummaryrefslogtreecommitdiff
path: root/pkg/config/yaml.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkg/config/yaml.go9
1 files changed, 9 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)
}