@ -47,6 +47,55 @@ type Block struct {
Computed bool
}
// AssertNoLegacyBehavior indicates that we are certain the schema is not relying on
// any legacy SDK behavior. We do this by checking for options which did not
// exist at the time of the legacy SDK, like structural attributes, certain
// complex types, or computed blocks.
func ( b Block ) AssertNoLegacyBehavior ( ) bool {
if b . Computed {
return true
}
// check for non-legacy attribute types
for _ , attr := range b . Attributes {
// A nested type cannot come from the SDK
if attr . NestedType != nil {
return true
}
ty := attr . Type
// Lists and sets of objects could be generated by
// SchemaConfigModeAttr, but some other combinations can be ruled out.
// Tuples and objects could not be generated at all.
if ty . IsTupleType ( ) || ty . IsObjectType ( ) {
return true
}
// A map of objects was not possible.
if ty . IsMapType ( ) && ty . ElementType ( ) . IsObjectType ( ) {
return true
}
// Nested collections were not really supported, but could be generated
// with string types (though we conservatively limit this to primitive types)
if ty . IsCollectionType ( ) {
ety := ty . ElementType ( )
if ety . IsCollectionType ( ) && ! ety . ElementType ( ) . IsPrimitiveType ( ) {
return true
}
}
}
for _ , nb := range b . BlockTypes {
if nb . Block . AssertNoLegacyBehavior ( ) {
return true
}
}
return false
}
// Attribute represents a configuration attribute, within a block.
type Attribute struct {
// Type is a type specification that the attribute's value must conform to.
@ -92,7 +141,7 @@ type Attribute struct {
// This is valid only when Deprecated is true.
DeprecationMessage string
// WriteOnly, if set to true, indicates that the attribute is not p r esisted
// WriteOnly, if set to true, indicates that the attribute is not p er sisted
// in the state.
WriteOnly bool
}