in tpgtools/property.go [327:360]
func (p Property) DefaultStateSetter() string {
switch p.Type.String() {
case SchemaTypeBool:
fallthrough
case SchemaTypeString:
fallthrough
case SchemaTypeInt:
fallthrough
case SchemaTypeFloat:
fallthrough
case SchemaTypeMap:
if p.IsResourceLabels() || p.IsResourceAnnotations() {
return fmt.Sprintf("d.Set(%q, flatten%s%s(res.%s, d))", p.Name(), p.resource.PathType(), p.PackagePath(), p.PackageName)
}
return fmt.Sprintf("d.Set(%q, res.%s)", p.Name(), p.PackageName)
case SchemaTypeList, SchemaTypeSet:
if p.IsComplexMap() {
return fmt.Sprintf("d.Set(%q, flatten%s%sMap(res.%s))", p.Name(), p.resource.PathType(), p.PackagePath(), p.PackageName)
}
if p.typ.Items != nil && ((p.typ.Items.Type == "string" && len(p.typ.Items.Enum) == 0) || p.typ.Items.Type == "integer") {
return fmt.Sprintf("d.Set(%q, res.%s)", p.Name(), p.PackageName)
}
if p.typ.Items != nil && (len(p.Properties) > 0 || len(p.typ.Items.Enum) > 0) {
return fmt.Sprintf("d.Set(%q, flatten%s%sArray(res.%s))", p.Name(), p.resource.PathType(), p.PackagePath(), p.PackageName)
}
}
if p.typ.Type == "object" {
return fmt.Sprintf("d.Set(%q, flatten%s%s(res.%s))", p.Name(), p.resource.PathType(), p.PackagePath(), p.PackageName)
}
return "<unknown>"
}