summaryrefslogtreecommitdiff
path: root/config/reader.go
diff options
context:
space:
mode:
Diffstat (limited to 'config/reader.go')
-rw-r--r--config/reader.go20
1 files changed, 18 insertions, 2 deletions
diff --git a/config/reader.go b/config/reader.go
index 378d523..4386aa7 100644
--- a/config/reader.go
+++ b/config/reader.go
@@ -91,11 +91,27 @@ func ExpandVariant(config *Config, name string) (*VariantConfig, error) {
// ReadConfig unmarshals the given YAML bytes into a new Config struct.
//
func ReadConfig(data []byte) (*Config, error) {
- var config Config
+ var (
+ version VersionConfig
+ config Config
+ )
+ // Unmarshal (un-strictly) config version first for pre-validation
+ err := yaml.Unmarshal(data, &version)
+
+ if err != nil {
+ return nil, err
+ }
+
+ if err = Validate(version); err != nil {
+ return nil, err
+ }
+
+ // Unmarshal the default config
yaml.Unmarshal([]byte(DefaultConfig), &config)
- err := yaml.Unmarshal(data, &config)
+ // And finally strictly unmarshal the entire user-provided config
+ err = yaml.UnmarshalStrict(data, &config)
if err != nil {
return nil, err