use strict unmarshalling to ensure correct configuration

This commit is contained in:
Tanner Bruce 2018-08-09 16:30:06 -05:00
parent 1667f1082b
commit 1ec7809eaf

View file

@ -25,7 +25,7 @@ func FromFile(filename string) (*MetricsDiscoveryConfig, error) {
// FromYAML loads the configuration from a blob of YAML. // FromYAML loads the configuration from a blob of YAML.
func FromYAML(contents []byte) (*MetricsDiscoveryConfig, error) { func FromYAML(contents []byte) (*MetricsDiscoveryConfig, error) {
var cfg MetricsDiscoveryConfig var cfg MetricsDiscoveryConfig
if err := yaml.Unmarshal(contents, &cfg); err != nil { if err := yaml.UnmarshalStrict(contents, &cfg); err != nil {
return nil, fmt.Errorf("unable to parse metrics discovery config: %v", err) return nil, fmt.Errorf("unable to parse metrics discovery config: %v", err)
} }
return &cfg, nil return &cfg, nil