Print short []s and {}s for empty arrays/maps
@@ -463,20 +463,30 @@ func printPropertyValue(b *bytes.Buffer, v resource.PropertyValue, planning bool
} else if v.IsString() {
b.WriteString(fmt.Sprintf("%q", v.StringValue()))
} else if v.IsArray() {
+ arr := v.ArrayValue()
+ if len(arr) == 0 {
+ b.WriteString("[]")
+ } else {
b.WriteString(fmt.Sprintf("[\n"))
- for i, elem := range v.ArrayValue() {
+ for i, elem := range arr {
newIndent := printArrayElemHeader(b, i, indent)
printPropertyValue(b, elem, planning, newIndent)
}
b.WriteString(fmt.Sprintf("%s]", indent))
+ }
} else if v.IsComputed() || v.IsOutput() {
b.WriteString(v.TypeString())
} else {
contract.Assert(v.IsObject())
+ obj := v.ObjectValue()
+ if len(obj) == 0 {
+ b.WriteString("{}")
+ } else {
b.WriteString("{\n")
- printObject(b, v.ObjectValue(), planning, indent+" ")
+ printObject(b, obj, planning, indent+" ")
b.WriteString(fmt.Sprintf("%s}", indent))
}
+ }
b.WriteString("\n")
}
