Skip to content

Commit a641162

Browse files
committed
config: interprets '~' as the current user home dir in file()
1 parent 19d6fdf commit a641162

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

config/interpolate_funcs.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strings"
1010

1111
"github.com/hashicorp/terraform/config/lang/ast"
12+
"github.com/mitchellh/go-homedir"
1213
)
1314

1415
// Funcs is the mapping of built-in functions for configuration.
@@ -57,7 +58,12 @@ func interpolationFuncFile() ast.Function {
5758
ArgTypes: []ast.Type{ast.TypeString},
5859
ReturnType: ast.TypeString,
5960
Callback: func(args []interface{}) (interface{}, error) {
60-
data, err := ioutil.ReadFile(args[0].(string))
61+
var path string
62+
path, err := homedir.Expand(args[0].(string))
63+
if err != nil {
64+
return "", err
65+
}
66+
data, err := ioutil.ReadFile(path)
6167
if err != nil {
6268
return "", err
6369
}

0 commit comments

Comments
 (0)