@ -8,9 +8,7 @@ import (
)
// CoerceValue attempts to force the given value to conform to the type
// implied by the receiever, while also applying the same validation and
// transformation rules that would be applied by the decoder specification
// returned by method DecoderSpec.
// implied by the receiever.
//
// This is useful in situations where a configuration must be derived from
// an already-decoded value. It is always better to decode directly from
@ -83,16 +81,8 @@ func (b *Block) coerceValue(in cty.Value, path cty.Path) (cty.Value, error) {
if err != nil {
return cty . UnknownVal ( b . ImpliedType ( ) ) , err
}
case blockS . MinItems != 1 && blockS . MaxItems != 1 :
if blockS . Nesting == NestingGroup {
attrs [ typeName ] = blockS . EmptyValue ( )
} else {
attrs [ typeName ] = cty . NullVal ( blockS . ImpliedType ( ) )
}
default :
// We use the word "attribute" here because we're talking about
// the cty sense of that word rather than the HCL sense.
return cty . UnknownVal ( b . ImpliedType ( ) ) , path . NewErrorf ( "attribute %q is required" , typeName )
attrs [ typeName ] = blockS . EmptyValue ( )
}
case NestingList :