From cfe3eee547a63c68dbfcb603b4be27bf023d64c9 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 18 Sep 2013 16:18:39 -0700 Subject: [PATCH] common: Allow user variables to be used for ints/bools/etc. [GH-418] --- CHANGELOG.md | 2 ++ common/config.go | 5 +++-- website/source/docs/templates/user-variables.html.markdown | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddf709bba..1c167e1d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ FEATURES: IMPROVEMENTS: +* core: User variables can now be used for integer, boolean, etc. + values. [GH-418] * builder/amazon/all: Interrupts work while waiting for AMI to be ready. BUG FIXES: diff --git a/common/config.go b/common/config.go index 2a2c8b21f..b579562d5 100644 --- a/common/config.go +++ b/common/config.go @@ -41,8 +41,9 @@ func CheckUnusedConfig(md *mapstructure.Metadata) *packer.MultiError { func DecodeConfig(target interface{}, raws ...interface{}) (*mapstructure.Metadata, error) { var md mapstructure.Metadata decoderConfig := &mapstructure.DecoderConfig{ - Metadata: &md, - Result: target, + Metadata: &md, + Result: target, + WeaklyTypedInput: true, } decoder, err := mapstructure.NewDecoder(decoderConfig) diff --git a/website/source/docs/templates/user-variables.html.markdown b/website/source/docs/templates/user-variables.html.markdown index 8f19aadea..edce239ad 100644 --- a/website/source/docs/templates/user-variables.html.markdown +++ b/website/source/docs/templates/user-variables.html.markdown @@ -54,7 +54,7 @@ validation will fail. Using the variables is extremely easy. Variables are used by calling the user function in the form of {{user `variable`}}. -This function can be used in _any string_ within the template, in +This function can be used in _any value_ within the template, in builders, provisioners, _anything_. The user variable is available globally within the template.