Merge pull request #1338 from 7heo/master

config: interprets '~' as the current user home dir in file()
This commit is contained in:
Paul Hinze 2015-03-30 18:59:37 -05:00
commit f9d92610d1
1 changed files with 7 additions and 1 deletions

View File

@ -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
}