Bump github.com/hashicorp/terraform-plugin-sdk/v2 from 2.20.0 to 2.24.1
Bumps [github.com/hashicorp/terraform-plugin-sdk/v2](https://github.com/hashicorp/terraform-plugin-sdk) from 2.20.0 to 2.24.1. - [Release notes](https://github.com/hashicorp/terraform-plugin-sdk/releases) - [Changelog](https://github.com/hashicorp/terraform-plugin-sdk/blob/main/CHANGELOG.md) - [Commits](https://github.com/hashicorp/terraform-plugin-sdk/compare/v2.20.0...v2.24.1) --- updated-dependencies: - dependency-name: github.com/hashicorp/terraform-plugin-sdk/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
4
vendor/github.com/zclconf/go-cty/cty/convert/conversion.go
generated
vendored
4
vendor/github.com/zclconf/go-cty/cty/convert/conversion.go
generated
vendored
@ -43,14 +43,14 @@ func getConversion(in cty.Type, out cty.Type, unsafe bool) conversion {
|
||||
out = out.WithoutOptionalAttributesDeep()
|
||||
|
||||
if !isKnown {
|
||||
return cty.UnknownVal(out), nil
|
||||
return cty.UnknownVal(dynamicReplace(in.Type(), out)), nil
|
||||
}
|
||||
|
||||
if isNull {
|
||||
// We'll pass through nulls, albeit type converted, and let
|
||||
// the caller deal with whatever handling they want to do in
|
||||
// case null values are considered valid in some applications.
|
||||
return cty.NullVal(out), nil
|
||||
return cty.NullVal(dynamicReplace(in.Type(), out)), nil
|
||||
}
|
||||
}
|
||||
|
||||
|
81
vendor/github.com/zclconf/go-cty/cty/convert/conversion_collection.go
generated
vendored
81
vendor/github.com/zclconf/go-cty/cty/convert/conversion_collection.go
generated
vendored
@ -39,6 +39,11 @@ func conversionCollectionToList(ety cty.Type, conv conversion) conversion {
|
||||
return cty.NilVal, err
|
||||
}
|
||||
}
|
||||
|
||||
if val.IsNull() {
|
||||
val = cty.NullVal(val.Type().WithoutOptionalAttributesDeep())
|
||||
}
|
||||
|
||||
elems = append(elems, val)
|
||||
|
||||
i++
|
||||
@ -50,7 +55,7 @@ func conversionCollectionToList(ety cty.Type, conv conversion) conversion {
|
||||
if ety == cty.DynamicPseudoType {
|
||||
return cty.ListValEmpty(val.Type().ElementType()), nil
|
||||
}
|
||||
return cty.ListValEmpty(ety), nil
|
||||
return cty.ListValEmpty(ety.WithoutOptionalAttributesDeep()), nil
|
||||
}
|
||||
|
||||
if !cty.CanListVal(elems) {
|
||||
@ -88,6 +93,11 @@ func conversionCollectionToSet(ety cty.Type, conv conversion) conversion {
|
||||
return cty.NilVal, err
|
||||
}
|
||||
}
|
||||
|
||||
if val.IsNull() {
|
||||
val = cty.NullVal(val.Type().WithoutOptionalAttributesDeep())
|
||||
}
|
||||
|
||||
elems = append(elems, val)
|
||||
|
||||
i++
|
||||
@ -99,7 +109,7 @@ func conversionCollectionToSet(ety cty.Type, conv conversion) conversion {
|
||||
if ety == cty.DynamicPseudoType {
|
||||
return cty.SetValEmpty(val.Type().ElementType()), nil
|
||||
}
|
||||
return cty.SetValEmpty(ety), nil
|
||||
return cty.SetValEmpty(ety.WithoutOptionalAttributesDeep()), nil
|
||||
}
|
||||
|
||||
if !cty.CanSetVal(elems) {
|
||||
@ -180,7 +190,7 @@ func conversionTupleToSet(tupleType cty.Type, setEty cty.Type, unsafe bool) conv
|
||||
if len(tupleEtys) == 0 {
|
||||
// Empty tuple short-circuit
|
||||
return func(val cty.Value, path cty.Path) (cty.Value, error) {
|
||||
return cty.SetValEmpty(setEty), nil
|
||||
return cty.SetValEmpty(setEty.WithoutOptionalAttributesDeep()), nil
|
||||
}
|
||||
}
|
||||
|
||||
@ -242,6 +252,11 @@ func conversionTupleToSet(tupleType cty.Type, setEty cty.Type, unsafe bool) conv
|
||||
return cty.NilVal, err
|
||||
}
|
||||
}
|
||||
|
||||
if val.IsNull() {
|
||||
val = cty.NullVal(val.Type().WithoutOptionalAttributesDeep())
|
||||
}
|
||||
|
||||
elems = append(elems, val)
|
||||
|
||||
i++
|
||||
@ -265,7 +280,7 @@ func conversionTupleToList(tupleType cty.Type, listEty cty.Type, unsafe bool) co
|
||||
if len(tupleEtys) == 0 {
|
||||
// Empty tuple short-circuit
|
||||
return func(val cty.Value, path cty.Path) (cty.Value, error) {
|
||||
return cty.ListValEmpty(listEty), nil
|
||||
return cty.ListValEmpty(listEty.WithoutOptionalAttributesDeep()), nil
|
||||
}
|
||||
}
|
||||
|
||||
@ -357,7 +372,7 @@ func conversionObjectToMap(objectType cty.Type, mapEty cty.Type, unsafe bool) co
|
||||
if len(objectAtys) == 0 {
|
||||
// Empty object short-circuit
|
||||
return func(val cty.Value, path cty.Path) (cty.Value, error) {
|
||||
return cty.MapValEmpty(mapEty), nil
|
||||
return cty.MapValEmpty(mapEty.WithoutOptionalAttributesDeep()), nil
|
||||
}
|
||||
}
|
||||
|
||||
@ -448,13 +463,28 @@ func conversionMapToObject(mapType cty.Type, objType cty.Type, unsafe bool) conv
|
||||
|
||||
elemConvs[name] = getConversion(mapEty, objectAty, unsafe)
|
||||
if elemConvs[name] == nil {
|
||||
// If any of our element conversions are impossible, then the our
|
||||
// whole conversion is impossible.
|
||||
// This means that this conversion is impossible. Typically, we
|
||||
// would give up at this point and declare the whole conversion
|
||||
// impossible. But, if this attribute is optional then maybe we will
|
||||
// be able to do this conversion anyway provided the actual concrete
|
||||
// map doesn't have this value set.
|
||||
//
|
||||
// We only do this in "unsafe" mode, because we cannot guarantee
|
||||
// that the returned conversion will actually succeed once applied.
|
||||
if objType.AttributeOptional(name) && unsafe {
|
||||
// This attribute is optional, so let's leave this conversion in
|
||||
// as a nil, and we can error later if we actually have to
|
||||
// convert this.
|
||||
continue
|
||||
}
|
||||
|
||||
// Otherwise, give up. This conversion is impossible as we have a
|
||||
// required attribute that doesn't match the map's inner type.
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// If we fall out here then a conversion is possible, using the
|
||||
// If we fall out here then a conversion may be possible, using the
|
||||
// element conversions in elemConvs
|
||||
return func(val cty.Value, path cty.Path) (cty.Value, error) {
|
||||
elems := make(map[string]cty.Value, len(elemConvs))
|
||||
@ -474,12 +504,43 @@ func conversionMapToObject(mapType cty.Type, objType cty.Type, unsafe bool) conv
|
||||
Key: name,
|
||||
}
|
||||
|
||||
conv := elemConvs[name.AsString()]
|
||||
if conv != nil {
|
||||
// There are 3 cases here:
|
||||
// 1. This attribute is not in elemConvs
|
||||
// 2. This attribute is in elemConvs and is not nil
|
||||
// 3. This attribute is in elemConvs and is nil.
|
||||
|
||||
// In case 1, we do not enter any of the branches below. This case
|
||||
// means the attribute type is the same between the map and the
|
||||
// object, and we don't need to do any conversion.
|
||||
|
||||
if conv, ok := elemConvs[name.AsString()]; conv != nil {
|
||||
// This is case 2. The attribute type is different between the
|
||||
// map and the object, and we know how to convert between them.
|
||||
// So, we reset val to be the converted value and carry on.
|
||||
val, err = conv(val, elemPath)
|
||||
if err != nil {
|
||||
return cty.NilVal, err
|
||||
}
|
||||
} else if ok {
|
||||
// This is case 3 and it is an error. The attribute types are
|
||||
// different between the map and the object, but we cannot
|
||||
// convert between them.
|
||||
//
|
||||
// Now typically, this would be picked earlier on when we were
|
||||
// building elemConvs. However, in the case of optional
|
||||
// attributes there was a chance we could still convert the
|
||||
// overall object even if this particular attribute was not
|
||||
// convertable. This is because it could have not been set in
|
||||
// the map, and we could skip over it here and set a null value.
|
||||
//
|
||||
// Since we reached this branch, we know that map did actually
|
||||
// contain a non-convertable optional attribute. This means we
|
||||
// error.
|
||||
return cty.NilVal, path.NewErrorf("map element type is incompatible with attribute %q: %s", name.AsString(), MismatchMessage(val.Type(), objType.AttributeType(name.AsString())))
|
||||
}
|
||||
|
||||
if val.IsNull() {
|
||||
val = cty.NullVal(val.Type().WithoutOptionalAttributesDeep())
|
||||
}
|
||||
|
||||
elems[name.AsString()] = val
|
||||
|
104
vendor/github.com/zclconf/go-cty/cty/convert/conversion_dynamic.go
generated
vendored
104
vendor/github.com/zclconf/go-cty/cty/convert/conversion_dynamic.go
generated
vendored
@ -31,3 +31,107 @@ func dynamicFixup(wantType cty.Type) conversion {
|
||||
func dynamicPassthrough(in cty.Value, path cty.Path) (cty.Value, error) {
|
||||
return in, nil
|
||||
}
|
||||
|
||||
// dynamicReplace aims to return the out type unchanged, but if it finds a
|
||||
// dynamic type either directly or in any descendent elements it replaces them
|
||||
// with the equivalent type from in.
|
||||
//
|
||||
// This function assumes that in and out are compatible from a Convert
|
||||
// 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
|
||||
// through both as if they were the same.
|
||||
func dynamicReplace(in, out cty.Type) cty.Type {
|
||||
if in == cty.DynamicPseudoType || in == cty.NilType {
|
||||
// Short circuit this case, there's no point worrying about this if in
|
||||
// is a dynamic type or a nil type. Out is the best we can do.
|
||||
return out
|
||||
}
|
||||
|
||||
switch {
|
||||
case out == cty.DynamicPseudoType:
|
||||
// So replace out with in.
|
||||
return in
|
||||
case out.IsPrimitiveType(), out.IsCapsuleType():
|
||||
// out is not dynamic and it doesn't contain descendent elements so just
|
||||
// return it unchanged.
|
||||
return out
|
||||
case out.IsMapType():
|
||||
var elemType cty.Type
|
||||
|
||||
// Maps are compatible with other maps or objects.
|
||||
if in.IsMapType() {
|
||||
elemType = dynamicReplace(in.ElementType(), out.ElementType())
|
||||
}
|
||||
|
||||
if in.IsObjectType() {
|
||||
var types []cty.Type
|
||||
for _, t := range in.AttributeTypes() {
|
||||
types = append(types, t)
|
||||
}
|
||||
unifiedType, _ := unify(types, true)
|
||||
elemType = dynamicReplace(unifiedType, out.ElementType())
|
||||
}
|
||||
|
||||
return cty.Map(elemType)
|
||||
case out.IsObjectType():
|
||||
// Objects are compatible with other objects and maps.
|
||||
outTypes := map[string]cty.Type{}
|
||||
if in.IsMapType() {
|
||||
for attr, attrType := range out.AttributeTypes() {
|
||||
outTypes[attr] = dynamicReplace(in.ElementType(), attrType)
|
||||
}
|
||||
}
|
||||
|
||||
if in.IsObjectType() {
|
||||
for attr, attrType := range out.AttributeTypes() {
|
||||
if !in.HasAttribute(attr) {
|
||||
// If in does not have this attribute, then it is an
|
||||
// optional attribute and there is nothing we can do except
|
||||
// to return the type from out even if it is dynamic.
|
||||
outTypes[attr] = attrType
|
||||
continue
|
||||
}
|
||||
outTypes[attr] = dynamicReplace(in.AttributeType(attr), attrType)
|
||||
}
|
||||
}
|
||||
|
||||
return cty.Object(outTypes)
|
||||
case out.IsSetType():
|
||||
var elemType cty.Type
|
||||
|
||||
// Sets are compatible with other sets, lists, tuples.
|
||||
if in.IsSetType() || in.IsListType() {
|
||||
elemType = dynamicReplace(in.ElementType(), out.ElementType())
|
||||
}
|
||||
|
||||
if in.IsTupleType() {
|
||||
unifiedType, _ := unify(in.TupleElementTypes(), true)
|
||||
elemType = dynamicReplace(unifiedType, out.ElementType())
|
||||
}
|
||||
|
||||
return cty.Set(elemType)
|
||||
case out.IsListType():
|
||||
var elemType cty.Type
|
||||
|
||||
// Lists are compatible with other lists, sets, and tuples.
|
||||
if in.IsSetType() || in.IsListType() {
|
||||
elemType = dynamicReplace(in.ElementType(), out.ElementType())
|
||||
}
|
||||
|
||||
if in.IsTupleType() {
|
||||
unifiedType, _ := unify(in.TupleElementTypes(), true)
|
||||
elemType = dynamicReplace(unifiedType, out.ElementType())
|
||||
}
|
||||
|
||||
return cty.List(elemType)
|
||||
case out.IsTupleType():
|
||||
// Tuples are only compatible with other tuples
|
||||
var types []cty.Type
|
||||
for ix := 0; ix < len(out.TupleElementTypes()); ix++ {
|
||||
types = append(types, dynamicReplace(in.TupleElementType(ix), out.TupleElementType(ix)))
|
||||
}
|
||||
return cty.Tuple(types)
|
||||
default:
|
||||
panic("unrecognized type " + out.FriendlyName())
|
||||
}
|
||||
}
|
||||
|
8
vendor/github.com/zclconf/go-cty/cty/convert/conversion_object.go
generated
vendored
8
vendor/github.com/zclconf/go-cty/cty/convert/conversion_object.go
generated
vendored
@ -80,13 +80,19 @@ func conversionObjectToObject(in, out cty.Type, unsafe bool) conversion {
|
||||
}
|
||||
}
|
||||
|
||||
if val.IsNull() {
|
||||
// Strip optional attributes out of the embedded type for null
|
||||
// values.
|
||||
val = cty.NullVal(val.Type().WithoutOptionalAttributesDeep())
|
||||
}
|
||||
|
||||
attrVals[name] = val
|
||||
}
|
||||
|
||||
for name := range outOptionals {
|
||||
if _, exists := attrVals[name]; !exists {
|
||||
wantTy := outAtys[name]
|
||||
attrVals[name] = cty.NullVal(wantTy)
|
||||
attrVals[name] = cty.NullVal(wantTy.WithoutOptionalAttributesDeep())
|
||||
}
|
||||
}
|
||||
|
||||
|
2
vendor/github.com/zclconf/go-cty/cty/convert/public.go
generated
vendored
2
vendor/github.com/zclconf/go-cty/cty/convert/public.go
generated
vendored
@ -40,7 +40,7 @@ func GetConversionUnsafe(in cty.Type, out cty.Type) Conversion {
|
||||
// This is a convenience wrapper around calling GetConversionUnsafe and then
|
||||
// immediately passing the given value to the resulting function.
|
||||
func Convert(in cty.Value, want cty.Type) (cty.Value, error) {
|
||||
if in.Type().Equals(want) {
|
||||
if in.Type().Equals(want.WithoutOptionalAttributesDeep()) {
|
||||
return in, nil
|
||||
}
|
||||
|
||||
|
5
vendor/github.com/zclconf/go-cty/cty/convert/unify.go
generated
vendored
5
vendor/github.com/zclconf/go-cty/cty/convert/unify.go
generated
vendored
@ -447,7 +447,6 @@ func unifyTupleTypes(types []cty.Type, unsafe bool, hasDynamic bool) (cty.Type,
|
||||
conversions[i] = GetConversion(ty, retTy)
|
||||
}
|
||||
if conversions[i] == nil {
|
||||
// Shouldn't be reachable, since we were able to unify
|
||||
return unifyTupleTypesToList(types, unsafe)
|
||||
}
|
||||
}
|
||||
@ -483,8 +482,8 @@ func unifyTupleTypesToList(types []cty.Type, unsafe bool) (cty.Type, []Conversio
|
||||
conversions[i] = GetConversion(ty, retTy)
|
||||
}
|
||||
if conversions[i] == nil {
|
||||
// Shouldn't be reachable, since we were able to unify
|
||||
return unifyObjectTypesToMap(types, unsafe)
|
||||
// no conversion was found
|
||||
return cty.NilType, nil
|
||||
}
|
||||
}
|
||||
return retTy, conversions
|
||||
|
Reference in New Issue
Block a user