vendor: update github.com/zclconf/go-cty to v1.14.4

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2024-04-09 09:41:03 +02:00
parent 744c055560
commit ea3338c3f3
No known key found for this signature in database
GPG Key ID: ADE44D8C9D44FBE4
8 changed files with 45 additions and 29 deletions

2
go.mod
View File

@ -40,7 +40,7 @@ require (
github.com/spf13/pflag v1.0.5 github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4 github.com/stretchr/testify v1.8.4
github.com/tonistiigi/fsutil v0.0.0-20240301111122-7525a1af2bb5 github.com/tonistiigi/fsutil v0.0.0-20240301111122-7525a1af2bb5
github.com/zclconf/go-cty v1.14.1 github.com/zclconf/go-cty v1.14.4
go.opentelemetry.io/otel v1.21.0 go.opentelemetry.io/otel v1.21.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.42.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.42.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v0.42.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v0.42.0 // indirect

4
go.sum
View File

@ -462,8 +462,8 @@ github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQ
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/zclconf/go-cty v1.4.0/go.mod h1:nHzOclRkoj++EU9ZjSrZvRG0BXIWt8c7loYc0qXAFGQ= github.com/zclconf/go-cty v1.4.0/go.mod h1:nHzOclRkoj++EU9ZjSrZvRG0BXIWt8c7loYc0qXAFGQ=
github.com/zclconf/go-cty v1.14.1 h1:t9fyA35fwjjUMcmL5hLER+e/rEPqrbCK1/OSE4SI9KA= github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8=
github.com/zclconf/go-cty v1.14.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b h1:FosyBZYxY34Wul7O/MSKey3txpPYyCqVO5ZyceuQJEI= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b h1:FosyBZYxY34Wul7O/MSKey3txpPYyCqVO5ZyceuQJEI=
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8=
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=

View File

@ -40,6 +40,11 @@ func dynamicPassthrough(in cty.Value, path cty.Path) (cty.Value, error) {
// perspective, and will panic if it finds that they are not. For example if // perspective, and will panic if it finds that they are not. For example if
// in is an object and out is a map, this function will still attempt to iterate // in is an object and out is a map, this function will still attempt to iterate
// through both as if they were the same. // through both as if they were the same.
// While the outermost in and out types may be compatible from a Convert
// perspective, inner types may not match when converting between maps and
// objects with optional attributes when the optional attributes don't match
// the map element type. Therefor in the case of a non-primitive type mismatch,
// we have to assume conversion was possible and pass the out type through.
func dynamicReplace(in, out cty.Type) cty.Type { func dynamicReplace(in, out cty.Type) cty.Type {
if in == cty.DynamicPseudoType || in == cty.NilType { if in == cty.DynamicPseudoType || in == cty.NilType {
// Short circuit this case, there's no point worrying about this if in // Short circuit this case, there's no point worrying about this if in
@ -56,11 +61,9 @@ func dynamicReplace(in, out cty.Type) cty.Type {
// return it unchanged. // return it unchanged.
return out return out
case out.IsMapType(): case out.IsMapType():
var elemType cty.Type
// Maps are compatible with other maps or objects. // Maps are compatible with other maps or objects.
if in.IsMapType() { if in.IsMapType() {
elemType = dynamicReplace(in.ElementType(), out.ElementType()) return cty.Map(dynamicReplace(in.ElementType(), out.ElementType()))
} }
if in.IsObjectType() { if in.IsObjectType() {
@ -69,10 +72,10 @@ func dynamicReplace(in, out cty.Type) cty.Type {
types = append(types, t) types = append(types, t)
} }
unifiedType, _ := unify(types, true) unifiedType, _ := unify(types, true)
elemType = dynamicReplace(unifiedType, out.ElementType()) return cty.Map(dynamicReplace(unifiedType, out.ElementType()))
} }
return cty.Map(elemType) return out
case out.IsObjectType(): case out.IsObjectType():
// Objects are compatible with other objects and maps. // Objects are compatible with other objects and maps.
outTypes := map[string]cty.Type{} outTypes := map[string]cty.Type{}
@ -97,33 +100,29 @@ func dynamicReplace(in, out cty.Type) cty.Type {
return cty.Object(outTypes) return cty.Object(outTypes)
case out.IsSetType(): case out.IsSetType():
var elemType cty.Type
// Sets are compatible with other sets, lists, tuples. // Sets are compatible with other sets, lists, tuples.
if in.IsSetType() || in.IsListType() { if in.IsSetType() || in.IsListType() {
elemType = dynamicReplace(in.ElementType(), out.ElementType()) return cty.Set(dynamicReplace(in.ElementType(), out.ElementType()))
} }
if in.IsTupleType() { if in.IsTupleType() {
unifiedType, _ := unify(in.TupleElementTypes(), true) unifiedType, _ := unify(in.TupleElementTypes(), true)
elemType = dynamicReplace(unifiedType, out.ElementType()) return cty.Set(dynamicReplace(unifiedType, out.ElementType()))
} }
return cty.Set(elemType) return out
case out.IsListType(): case out.IsListType():
var elemType cty.Type
// Lists are compatible with other lists, sets, and tuples. // Lists are compatible with other lists, sets, and tuples.
if in.IsSetType() || in.IsListType() { if in.IsSetType() || in.IsListType() {
elemType = dynamicReplace(in.ElementType(), out.ElementType()) return cty.List(dynamicReplace(in.ElementType(), out.ElementType()))
} }
if in.IsTupleType() { if in.IsTupleType() {
unifiedType, _ := unify(in.TupleElementTypes(), true) unifiedType, _ := unify(in.TupleElementTypes(), true)
elemType = dynamicReplace(unifiedType, out.ElementType()) return cty.List(dynamicReplace(unifiedType, out.ElementType()))
} }
return cty.List(elemType) return out
case out.IsTupleType(): case out.IsTupleType():
// Tuples are only compatible with other tuples // Tuples are only compatible with other tuples
var types []cty.Type var types []cty.Type

View File

@ -1506,8 +1506,8 @@ func Keys(inputMap cty.Value) (cty.Value, error) {
} }
// Lookup performs a dynamic lookup into a map. // Lookup performs a dynamic lookup into a map.
// There are two required arguments, map and key, plus an optional default, // There are three required arguments, inputMap and key, plus a defaultValue,
// which is a value to return if no key is found in map. // which is a value to return if the given key is not found in the inputMap.
func Lookup(inputMap, key, defaultValue cty.Value) (cty.Value, error) { func Lookup(inputMap, key, defaultValue cty.Value) (cty.Value, error) {
return LookupFunc.Call([]cty.Value{inputMap, key, defaultValue}) return LookupFunc.Call([]cty.Value{inputMap, key, defaultValue})
} }

View File

@ -30,8 +30,9 @@ func MakeToFunc(wantTy cty.Type) function.Function {
// messages to be more appropriate for an explicit type // messages to be more appropriate for an explicit type
// conversion, whereas the cty function system produces // conversion, whereas the cty function system produces
// messages aimed at _implicit_ type conversions. // messages aimed at _implicit_ type conversions.
Type: cty.DynamicPseudoType, Type: cty.DynamicPseudoType,
AllowNull: true, AllowNull: true,
AllowDynamicType: true,
}, },
}, },
Type: func(args []cty.Value) (cty.Type, error) { Type: func(args []cty.Value) (cty.Type, error) {

View File

@ -12,6 +12,9 @@ func marshal(val cty.Value, t cty.Type, path cty.Path, b *bytes.Buffer) error {
if val.IsMarked() { if val.IsMarked() {
return path.NewErrorf("value has marks, so it cannot be serialized as JSON") return path.NewErrorf("value has marks, so it cannot be serialized as JSON")
} }
if !val.IsKnown() {
return path.NewErrorf("value is not known")
}
// If we're going to decode as DynamicPseudoType then we need to save // If we're going to decode as DynamicPseudoType then we need to save
// dynamic type information to recover the real type. // dynamic type information to recover the real type.
@ -24,10 +27,6 @@ func marshal(val cty.Value, t cty.Type, path cty.Path, b *bytes.Buffer) error {
return nil return nil
} }
if !val.IsKnown() {
return path.NewErrorf("value is not known")
}
// The caller should've guaranteed that the given val is conformant with // The caller should've guaranteed that the given val is conformant with
// the given type t, so we'll proceed under that assumption here. // the given type t, so we'll proceed under that assumption here.
@ -185,7 +184,10 @@ func marshalDynamic(val cty.Value, path cty.Path, b *bytes.Buffer) error {
return path.NewErrorf("failed to serialize type: %s", err) return path.NewErrorf("failed to serialize type: %s", err)
} }
b.WriteString(`{"value":`) b.WriteString(`{"value":`)
marshal(val, val.Type(), path, b) err = marshal(val, val.Type(), path, b)
if err != nil {
return path.NewErrorf("failed to serialize value: %s", err)
}
b.WriteString(`,"type":`) b.WriteString(`,"type":`)
b.Write(typeJSON) b.Write(typeJSON)
b.WriteRune('}') b.WriteRune('}')

View File

@ -1,6 +1,8 @@
package cty package cty
import "math/big" import (
"math/big"
)
// primitiveType is the hidden implementation of the various primitive types // primitiveType is the hidden implementation of the various primitive types
// that are exposed as variables in this package. // that are exposed as variables in this package.
@ -77,6 +79,18 @@ func rawNumberEqual(a, b *big.Float) bool {
case a.Sign() != b.Sign(): case a.Sign() != b.Sign():
return false return false
default: default:
// First check if these are integers, and compare them directly. Floats
// need a more nuanced approach.
aInt, aAcc := a.Int(nil)
bInt, bAcc := b.Int(nil)
if aAcc != bAcc {
// only one is an exact integer value, so they can't be equal
return false
}
if aAcc == big.Exact {
return aInt.Cmp(bInt) == 0
}
// This format and precision matches that used by cty/json.Marshal, // This format and precision matches that used by cty/json.Marshal,
// and thus achieves our definition of "two numbers are equal if // and thus achieves our definition of "two numbers are equal if
// we'd use the same JSON serialization for both of them". // we'd use the same JSON serialization for both of them".

2
vendor/modules.txt vendored
View File

@ -727,7 +727,7 @@ github.com/xeipuuv/gojsonreference
# github.com/xeipuuv/gojsonschema v1.2.0 # github.com/xeipuuv/gojsonschema v1.2.0
## explicit ## explicit
github.com/xeipuuv/gojsonschema github.com/xeipuuv/gojsonschema
# github.com/zclconf/go-cty v1.14.1 # github.com/zclconf/go-cty v1.14.4
## explicit; go 1.18 ## explicit; go 1.18
github.com/zclconf/go-cty/cty github.com/zclconf/go-cty/cty
github.com/zclconf/go-cty/cty/convert github.com/zclconf/go-cty/cty/convert