You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When comparing tftypes.Types using the Is method, we didn't used to
check if aggregate types were truly equal, with all their element or
attribute types matching. This was because we wanted to be able to
detect when something was an object, without caring about which
attributes or types of attributes it had, for e.g. casting purposes.
This enhancement checks if the type a type is being compared to has any
element or attribute types set. If so, the type will be deeply compared
against it, with all attribute and alement types needing to match. If
not, the old behavior will continue to work. This lets us do the
following:
```go
typ1 := tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"foo": tftypes.String,
"bar": tftypes.Number,
"quux": tftypes.List{
ElementTypes: tftypes.String,
},
},
}
typ1.Is(tftypes.Object{}) // true
typ1.Is(tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"foo": tftypes.String,
"bar": tftypes.Number,
"quux": tftypes.List{
ElementTypes: tftypes.String,
},
},
}) // true
typ1.Is(tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"foo": tftypes.String,
"bar": tftypes.Number,
"quux": tftypes.List{},
},
}) // true
typ1.Is(tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"foo": tftypes.String,
"bar": tftypes.Number,
},
}) // false
typ1.Is(tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"foo": tftypes.String,
"bar": tftypes.Number,
"quux": tftypes.List{
ElementTypes: tftypes.Number,
},
},
}) // false
typ1.Is(tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"foo": tftypes.String,
"bar": tftypes.String,
"quux": tftypes.List{
ElementTypes: tftypes.String,
},
},
}) // false
```
and so on.
0 commit comments