Commit bdb9bd7d authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

helper/config: error if unused keys

parent becd6dac
package config
import (
"fmt"
"reflect"
"sort"
"strings"
"github.com/hashicorp/go-multierror"
"github.com/mitchellh/mapstructure"
"github.com/mitchellh/packer/template/interpolate"
)
......@@ -70,6 +74,21 @@ func Decode(target interface{}, config *DecodeOpts, raws ...interface{}) error {
}
}
// If we have unused keys, it is an error
if len(md.Unused) > 0 {
var err error
sort.Strings(md.Unused)
for _, unused := range md.Unused {
if unused != "type" && !strings.HasPrefix(unused, "packer_") {
err = multierror.Append(err, fmt.Errorf(
"unknown configuration key: %q", unused))
}
}
if err != nil {
return err
}
}
return nil
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment