helper/config: support outputting metadata

This commit is contained in:
Mitchell Hashimoto 2015-05-27 12:55:41 -07:00
parent faf327eed0
commit 931f3eb7bc
1 changed files with 8 additions and 0 deletions

View File

@ -13,6 +13,9 @@ import (
// DecodeOpts are the options for decoding configuration.
type DecodeOpts struct {
// Metadata, if non-nil, will be set to the metadata post-decode
Metadata *mapstructure.Metadata
// Interpolate, if true, will automatically interpolate the
// configuration with the given InterpolateContext. User variables
// will be automatically detected and added in-place to the given
@ -74,6 +77,11 @@ func Decode(target interface{}, config *DecodeOpts, raws ...interface{}) error {
}
}
// Set the metadata if it is set
if config.Metadata != nil {
*config.Metadata = md
}
// If we have unused keys, it is an error
if len(md.Unused) > 0 {
var err error