summaryrefslogtreecommitdiff
path: root/context.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-05-22 14:32:12 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2019-05-22 14:32:12 -0600
commitf976451d19aea6db42d08ff8cf6e760176f94acb (patch)
tree47830639e62cd3ee0c048e217af128f6877f8fcc /context.go
parent869fbac632bc098f8d40fd7b43790fadce84ed1a (diff)
Disallow unknown fields (strict unmarshal) when loading modules
This makes it faster and easier to detect broken configurations, but is a slight performance hit on config loads since we have to re-encode the decoded struct back into JSON without the module name's key
Diffstat (limited to 'context.go')
-rw-r--r--context.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/context.go b/context.go
index bdf9f60..dab603e 100644
--- a/context.go
+++ b/context.go
@@ -84,7 +84,7 @@ func (ctx Context) LoadModule(name string, rawMsg json.RawMessage) (interface{},
// fill in its config only if there is a config to fill in
if len(rawMsg) > 0 {
- err := json.Unmarshal(rawMsg, &val)
+ err := strictUnmarshalJSON(rawMsg, &val)
if err != nil {
return nil, fmt.Errorf("decoding module config: %s: %v", mod.Name, err)
}
@@ -127,7 +127,7 @@ func (ctx Context) LoadModule(name string, rawMsg json.RawMessage) (interface{},
// containing the module name is treated special/separate from all
// the other keys.
func (ctx Context) LoadModuleInline(moduleNameKey, moduleScope string, raw json.RawMessage) (interface{}, error) {
- moduleName, err := getModuleNameInline(moduleNameKey, raw)
+ moduleName, raw, err := getModuleNameInline(moduleNameKey, raw)
if err != nil {
return nil, err
}