diff --git a/go.mod b/go.mod index aa4164674008..15aa1c8d8578 100644 --- a/go.mod +++ b/go.mod @@ -107,7 +107,7 @@ require ( github.com/xanzy/ssh-agent v0.2.1 github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 // indirect github.com/xlab/treeprint v0.0.0-20161029104018-1d6e34225557 - github.com/zclconf/go-cty v0.0.0-20190320224746-fd76348b9329 + github.com/zclconf/go-cty v0.0.0-20190425000443-8c00057b05d7 go.uber.org/atomic v1.3.2 // indirect go.uber.org/multierr v1.1.0 // indirect go.uber.org/zap v1.9.1 // indirect diff --git a/go.sum b/go.sum index 97548c7e3faf..dc41e4a4408f 100644 --- a/go.sum +++ b/go.sum @@ -401,8 +401,8 @@ github.com/xlab/treeprint v0.0.0-20161029104018-1d6e34225557/go.mod h1:ce1O1j6Ut github.com/zclconf/go-cty v0.0.0-20181129180422-88fbe721e0f8/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v0.0.0-20190124225737-a385d646c1e9 h1:hHCAGde+QfwbqXSAqOmBd4NlOrJ6nmjWp+Nu408ezD4= github.com/zclconf/go-cty v0.0.0-20190124225737-a385d646c1e9/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= -github.com/zclconf/go-cty v0.0.0-20190320224746-fd76348b9329 h1:ne520NlvoncW5zfBGkmP4EJhyd6ruSaSyhzobv0Vz9w= -github.com/zclconf/go-cty v0.0.0-20190320224746-fd76348b9329/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= +github.com/zclconf/go-cty v0.0.0-20190425000443-8c00057b05d7 h1:GppzGMnuVhCyg/BNYMI39tu1peZ1E/XVg+ZsLUyNdhk= +github.com/zclconf/go-cty v0.0.0-20190425000443-8c00057b05d7/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= go.opencensus.io v0.18.0 h1:Mk5rgZcggtbvtAun5aJzAtjKKN/t0R3jJPlWILlv938= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4= diff --git a/plans/objchange/compatible_test.go b/plans/objchange/compatible_test.go index ddd8a2850eb1..900edc08ad8d 100644 --- a/plans/objchange/compatible_test.go +++ b/plans/objchange/compatible_test.go @@ -1070,7 +1070,7 @@ func TestAssertObjectCompatible(t *testing.T) { }), }), []string{ - `.block: planned set element cty.Value{ty: cty.Object(map[string]cty.Type{"foo":cty.String}), v: map[string]interface {}{"foo":"hello"}} does not correlate with any element in actual`, + `.block: planned set element cty.ObjectVal(map[string]cty.Value{"foo":cty.StringVal("hello")}) does not correlate with any element in actual`, }, }, { diff --git a/vendor/github.com/zclconf/go-cty/cty/gocty/out.go b/vendor/github.com/zclconf/go-cty/cty/gocty/out.go index 99b65a767ce7..e9c2599e6c19 100644 --- a/vendor/github.com/zclconf/go-cty/cty/gocty/out.go +++ b/vendor/github.com/zclconf/go-cty/cty/gocty/out.go @@ -1,11 +1,10 @@ package gocty import ( + "math" "math/big" "reflect" - "math" - "github.com/zclconf/go-cty/cty" ) @@ -112,11 +111,7 @@ func fromCtyBool(val cty.Value, target reflect.Value, path cty.Path) error { switch target.Kind() { case reflect.Bool: - if val.True() { - target.Set(reflect.ValueOf(true)) - } else { - target.Set(reflect.ValueOf(false)) - } + target.SetBool(val.True()) return nil default: @@ -175,8 +170,7 @@ func fromCtyNumberInt(bf *big.Float, target reflect.Value, path cty.Path) error return path.NewErrorf("value must be a whole number, between %d and %d", min, max) } - target.Set(reflect.ValueOf(iv).Convert(target.Type())) - + target.SetInt(iv) return nil } @@ -202,25 +196,13 @@ func fromCtyNumberUInt(bf *big.Float, target reflect.Value, path cty.Path) error return path.NewErrorf("value must be a whole number, between 0 and %d inclusive", max) } - target.Set(reflect.ValueOf(iv).Convert(target.Type())) - + target.SetUint(iv) return nil } func fromCtyNumberFloat(bf *big.Float, target reflect.Value, path cty.Path) error { switch target.Kind() { - case reflect.Float32: - fv, accuracy := bf.Float32() - if accuracy != big.Exact { - // We allow the precision to be truncated as part of our conversion, - // but we don't want to silently introduce infinities. - if math.IsInf(float64(fv), 0) { - return path.NewErrorf("value must be between %f and %f inclusive", -math.MaxFloat32, math.MaxFloat32) - } - } - target.Set(reflect.ValueOf(fv)) - return nil - case reflect.Float64: + case reflect.Float32, reflect.Float64: fv, accuracy := bf.Float64() if accuracy != big.Exact { // We allow the precision to be truncated as part of our conversion, @@ -229,7 +211,7 @@ func fromCtyNumberFloat(bf *big.Float, target reflect.Value, path cty.Path) erro return path.NewErrorf("value must be between %f and %f inclusive", -math.MaxFloat64, math.MaxFloat64) } } - target.Set(reflect.ValueOf(fv)) + target.SetFloat(fv) return nil default: panic("unsupported kind of float") @@ -239,17 +221,17 @@ func fromCtyNumberFloat(bf *big.Float, target reflect.Value, path cty.Path) erro func fromCtyNumberBig(bf *big.Float, target reflect.Value, path cty.Path) error { switch { - case bigFloatType.AssignableTo(target.Type()): + case bigFloatType.ConvertibleTo(target.Type()): // Easy! - target.Set(reflect.ValueOf(bf).Elem()) + target.Set(reflect.ValueOf(bf).Elem().Convert(target.Type())) return nil - case bigIntType.AssignableTo(target.Type()): + case bigIntType.ConvertibleTo(target.Type()): bi, accuracy := bf.Int(nil) if accuracy != big.Exact { return path.NewErrorf("value must be a whole number") } - target.Set(reflect.ValueOf(bi).Elem()) + target.Set(reflect.ValueOf(bi).Elem().Convert(target.Type())) return nil default: @@ -259,9 +241,8 @@ func fromCtyNumberBig(bf *big.Float, target reflect.Value, path cty.Path) error func fromCtyString(val cty.Value, target reflect.Value, path cty.Path) error { switch target.Kind() { - case reflect.String: - target.Set(reflect.ValueOf(val.AsString())) + target.SetString(val.AsString()) return nil default: diff --git a/vendor/github.com/zclconf/go-cty/cty/path.go b/vendor/github.com/zclconf/go-cty/cty/path.go index 625bfdf85448..bf1a7c15aa01 100644 --- a/vendor/github.com/zclconf/go-cty/cty/path.go +++ b/vendor/github.com/zclconf/go-cty/cty/path.go @@ -51,6 +51,11 @@ func (p Path) Index(v Value) Path { return ret } +// IndexPath is a convenience method to start a new Path with an IndexStep. +func IndexPath(v Value) Path { + return Path{}.Index(v) +} + // GetAttr returns a new Path that is the reciever with a GetAttrStep appended // to the end. // @@ -66,6 +71,11 @@ func (p Path) GetAttr(name string) Path { return ret } +// GetAttrPath is a convenience method to start a new Path with a GetAttrStep. +func GetAttrPath(name string) Path { + return Path{}.GetAttr(name) +} + // Apply applies each of the steps in turn to successive values starting with // the given value, and returns the result. If any step returns an error, // the whole operation returns an error. diff --git a/vendor/github.com/zclconf/go-cty/cty/value_init.go b/vendor/github.com/zclconf/go-cty/cty/value_init.go index a9abbbb06fce..3deeba3bd3f6 100644 --- a/vendor/github.com/zclconf/go-cty/cty/value_init.go +++ b/vendor/github.com/zclconf/go-cty/cty/value_init.go @@ -56,6 +56,18 @@ func ParseNumberVal(s string) (Value, error) { return NumberVal(f), nil } +// MustParseNumberVal is like ParseNumberVal but it will panic in case of any +// error. It can be used during initialization or any other situation where +// the given string is a constant or otherwise known to be correct by the +// caller. +func MustParseNumberVal(s string) Value { + ret, err := ParseNumberVal(s) + if err != nil { + panic(err) + } + return ret +} + // NumberIntVal returns a Value of type Number whose internal value is equal // to the given integer. func NumberIntVal(v int64) Value { diff --git a/vendor/github.com/zclconf/go-cty/cty/value_ops.go b/vendor/github.com/zclconf/go-cty/cty/value_ops.go index 436f9b0b1ac6..afd621cf4ffa 100644 --- a/vendor/github.com/zclconf/go-cty/cty/value_ops.go +++ b/vendor/github.com/zclconf/go-cty/cty/value_ops.go @@ -3,12 +3,13 @@ package cty import ( "fmt" "math/big" - "reflect" "github.com/zclconf/go-cty/cty/set" ) +// GoString is an implementation of fmt.GoStringer that produces concise +// source-like representations of values suitable for use in debug messages. func (val Value) GoString() string { if val == NilVal { return "cty.NilVal" @@ -32,9 +33,8 @@ func (val Value) GoString() string { case Bool: if val.v.(bool) { return "cty.True" - } else { - return "cty.False" } + return "cty.False" case Number: fv := val.v.(*big.Float) // We'll try to use NumberIntVal or NumberFloatVal if we can, since @@ -45,19 +45,42 @@ func (val Value) GoString() string { if rfv, accuracy := fv.Float64(); accuracy == big.Exact { return fmt.Sprintf("cty.NumberFloatVal(%#v)", rfv) } - return fmt.Sprintf("cty.NumberVal(new(big.Float).Parse(\"%#v\", 10))", fv) + return fmt.Sprintf("cty.MustParseNumberVal(%q)", fv.Text('f', -1)) case String: return fmt.Sprintf("cty.StringVal(%#v)", val.v) } switch { case val.ty.IsSetType(): - vals := val.v.(set.Set).Values() - if vals == nil || len(vals) == 0 { - return fmt.Sprintf("cty.SetValEmpty()") - } else { - return fmt.Sprintf("cty.SetVal(%#v)", vals) + vals := val.AsValueSlice() + if len(vals) == 0 { + return fmt.Sprintf("cty.SetValEmpty(%#v)", val.ty.ElementType()) + } + return fmt.Sprintf("cty.SetVal(%#v)", vals) + case val.ty.IsListType(): + vals := val.AsValueSlice() + if len(vals) == 0 { + return fmt.Sprintf("cty.ListValEmpty(%#v)", val.ty.ElementType()) + } + return fmt.Sprintf("cty.ListVal(%#v)", vals) + case val.ty.IsMapType(): + vals := val.AsValueMap() + if len(vals) == 0 { + return fmt.Sprintf("cty.MapValEmpty(%#v)", val.ty.ElementType()) + } + return fmt.Sprintf("cty.MapVal(%#v)", vals) + case val.ty.IsTupleType(): + if val.ty.Equals(EmptyTuple) { + return "cty.EmptyTupleVal" + } + vals := val.AsValueSlice() + return fmt.Sprintf("cty.TupleVal(%#v)", vals) + case val.ty.IsObjectType(): + if val.ty.Equals(EmptyObject) { + return "cty.EmptyObjectVal" } + vals := val.AsValueMap() + return fmt.Sprintf("cty.ObjectVal(%#v)", vals) case val.ty.IsCapsuleType(): return fmt.Sprintf("cty.CapsuleVal(%#v, %#v)", val.ty, val.v) } diff --git a/vendor/modules.txt b/vendor/modules.txt index e27ec1637b79..e15c43c10781 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -434,7 +434,7 @@ github.com/vmihailenco/msgpack/codes github.com/xanzy/ssh-agent # github.com/xlab/treeprint v0.0.0-20161029104018-1d6e34225557 github.com/xlab/treeprint -# github.com/zclconf/go-cty v0.0.0-20190320224746-fd76348b9329 +# github.com/zclconf/go-cty v0.0.0-20190425000443-8c00057b05d7 github.com/zclconf/go-cty/cty github.com/zclconf/go-cty/cty/gocty github.com/zclconf/go-cty/cty/convert