From 931f3eb7bc82149a4e5363da0d7ac65447998e10 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 27 May 2015 12:55:41 -0700 Subject: [PATCH] helper/config: support outputting metadata --- helper/config/decode.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/helper/config/decode.go b/helper/config/decode.go index af4ca1aa2..73e470d27 100644 --- a/helper/config/decode.go +++ b/helper/config/decode.go @@ -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