From a6411626bf443abe2d121d43dcaff83b3d948733 Mon Sep 17 00:00:00 2001 From: 7heo <7heo@users.noreply.github.com> Date: Tue, 31 Mar 2015 01:52:39 +0200 Subject: [PATCH] config: interprets '~' as the current user home dir in file() --- config/interpolate_funcs.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/config/interpolate_funcs.go b/config/interpolate_funcs.go index 8bb76c532..6fa9dd1cb 100644 --- a/config/interpolate_funcs.go +++ b/config/interpolate_funcs.go @@ -9,6 +9,7 @@ import ( "strings" "github.com/hashicorp/terraform/config/lang/ast" + "github.com/mitchellh/go-homedir" ) // Funcs is the mapping of built-in functions for configuration. @@ -57,7 +58,12 @@ func interpolationFuncFile() ast.Function { ArgTypes: []ast.Type{ast.TypeString}, ReturnType: ast.TypeString, Callback: func(args []interface{}) (interface{}, error) { - data, err := ioutil.ReadFile(args[0].(string)) + var path string + path, err := homedir.Expand(args[0].(string)) + if err != nil { + return "", err + } + data, err := ioutil.ReadFile(path) if err != nil { return "", err }