config: interprets '~' as the current user home dir in file()
This commit is contained in:
parent
19d6fdfc34
commit
a6411626bf
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue