bump github.com/zclconf/go-cty from 1.7.1 to 1.10.0

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2022-01-13 14:32:10 +01:00
parent 785c861233
commit b67bdedb23
30 changed files with 13397 additions and 193 deletions

View File

@ -33,10 +33,15 @@ func walk(path Path, val Value, cb func(Path, Value) (bool, error)) error {
return nil
}
// The callback already got a chance to see the mark in our
// call above, so can safely strip it off here in order to
// visit the child elements, which might still have their own marks.
rawVal, _ := val.Unmark()
ty := val.Type()
switch {
case ty.IsObjectType():
for it := val.ElementIterator(); it.Next(); {
for it := rawVal.ElementIterator(); it.Next(); {
nameVal, av := it.Element()
path := append(path, GetAttrStep{
Name: nameVal.AsString(),
@ -46,8 +51,8 @@ func walk(path Path, val Value, cb func(Path, Value) (bool, error)) error {
return err
}
}
case val.CanIterateElements():
for it := val.ElementIterator(); it.Next(); {
case rawVal.CanIterateElements():
for it := rawVal.ElementIterator(); it.Next(); {
kv, ev := it.Element()
path := append(path, IndexStep{
Key: kv,
@ -134,6 +139,12 @@ func transform(path Path, val Value, t Transformer) (Value, error) {
ty := val.Type()
var newVal Value
// We need to peel off any marks here so that we can dig around
// inside any collection values. We'll reapply these to any
// new collections we construct, but the transformer's Exit
// method gets the final say on what to do with those.
rawVal, marks := val.Unmark()
switch {
case val.IsNull() || !val.IsKnown():
@ -141,14 +152,14 @@ func transform(path Path, val Value, t Transformer) (Value, error) {
newVal = val
case ty.IsListType() || ty.IsSetType() || ty.IsTupleType():
l := val.LengthInt()
l := rawVal.LengthInt()
switch l {
case 0:
// No deep transform for an empty sequence
newVal = val
default:
elems := make([]Value, 0, l)
for it := val.ElementIterator(); it.Next(); {
for it := rawVal.ElementIterator(); it.Next(); {
kv, ev := it.Element()
path := append(path, IndexStep{
Key: kv,
@ -161,25 +172,25 @@ func transform(path Path, val Value, t Transformer) (Value, error) {
}
switch {
case ty.IsListType():
newVal = ListVal(elems)
newVal = ListVal(elems).WithMarks(marks)
case ty.IsSetType():
newVal = SetVal(elems)
newVal = SetVal(elems).WithMarks(marks)
case ty.IsTupleType():
newVal = TupleVal(elems)
newVal = TupleVal(elems).WithMarks(marks)
default:
panic("unknown sequence type") // should never happen because of the case we are in
}
}
case ty.IsMapType():
l := val.LengthInt()
l := rawVal.LengthInt()
switch l {
case 0:
// No deep transform for an empty map
newVal = val
default:
elems := make(map[string]Value)
for it := val.ElementIterator(); it.Next(); {
for it := rawVal.ElementIterator(); it.Next(); {
kv, ev := it.Element()
path := append(path, IndexStep{
Key: kv,
@ -190,7 +201,7 @@ func transform(path Path, val Value, t Transformer) (Value, error) {
}
elems[kv.AsString()] = newEv
}
newVal = MapVal(elems)
newVal = MapVal(elems).WithMarks(marks)
}
case ty.IsObjectType():
@ -212,7 +223,7 @@ func transform(path Path, val Value, t Transformer) (Value, error) {
}
newAVs[name] = newAV
}
newVal = ObjectVal(newAVs)
newVal = ObjectVal(newAVs).WithMarks(marks)
}
default: