diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index dd820e1ee9..0274ff8bcd 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -685,11 +685,11 @@ }, { "ImportPath": "github.com/hashicorp/hil", - "Rev": "0457360d54ca4d081a769eaa1617e0462153fd70" + "Rev": "1586b586f59cfa528a751d4a62be88910d34e6e9" }, { "ImportPath": "github.com/hashicorp/hil/ast", - "Rev": "0457360d54ca4d081a769eaa1617e0462153fd70" + "Rev": "1586b586f59cfa528a751d4a62be88910d34e6e9" }, { "ImportPath": "github.com/hashicorp/logutils", diff --git a/vendor/github.com/hashicorp/hil/builtins.go b/vendor/github.com/hashicorp/hil/builtins.go index 0afa3e0278..8c8a34803c 100644 --- a/vendor/github.com/hashicorp/hil/builtins.go +++ b/vendor/github.com/hashicorp/hil/builtins.go @@ -22,6 +22,7 @@ func registerBuiltins(scope *ast.BasicScope) *ast.BasicScope { scope.FuncMap["__builtin_IntToFloat"] = builtinIntToFloat() scope.FuncMap["__builtin_IntToString"] = builtinIntToString() scope.FuncMap["__builtin_StringToInt"] = builtinStringToInt() + scope.FuncMap["__builtin_StringToFloat"] = builtinStringToFloat() // Math operations scope.FuncMap["__builtin_IntMath"] = builtinIntMath() @@ -142,3 +143,18 @@ func builtinStringToInt() ast.Function { }, } } + +func builtinStringToFloat() ast.Function { + return ast.Function{ + ArgTypes: []ast.Type{ast.TypeString}, + ReturnType: ast.TypeFloat, + Callback: func(args []interface{}) (interface{}, error) { + v, err := strconv.ParseFloat(args[0].(string), 64) + if err != nil { + return nil, err + } + + return v, nil + }, + } +} diff --git a/vendor/github.com/hashicorp/hil/check_types.go b/vendor/github.com/hashicorp/hil/check_types.go index afffffcf1c..3d157c597d 100644 --- a/vendor/github.com/hashicorp/hil/check_types.go +++ b/vendor/github.com/hashicorp/hil/check_types.go @@ -251,7 +251,7 @@ func (tc *typeCheckConcat) TypeCheck(v *TypeCheck) (ast.Node, error) { } return nil, fmt.Errorf( - "argument %d must be a string", i+1) + "output of an HIL expression must be a string (argument %d is %s)", i+1, t) } } diff --git a/vendor/github.com/hashicorp/hil/eval.go b/vendor/github.com/hashicorp/hil/eval.go index 6b81c760bc..dd948d72a1 100644 --- a/vendor/github.com/hashicorp/hil/eval.go +++ b/vendor/github.com/hashicorp/hil/eval.go @@ -41,7 +41,8 @@ func Eval(root ast.Node, config *EvalConfig) (interface{}, ast.Type, error) { ast.TypeString: "__builtin_IntToString", }, ast.TypeString: { - ast.TypeInt: "__builtin_StringToInt", + ast.TypeInt: "__builtin_StringToInt", + ast.TypeFloat: "__builtin_StringToFloat", }, }