|
|
|
|
@ -213,116 +213,3 @@ func formatStateModule(p blockBodyDiffPrinter, m *states.Module, schemas *terraf
|
|
|
|
|
}
|
|
|
|
|
p.buf.WriteString("\n")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func formatNestedList(indent string, outputList []interface{}) string {
|
|
|
|
|
outputBuf := new(bytes.Buffer)
|
|
|
|
|
outputBuf.WriteString(fmt.Sprintf("%s[", indent))
|
|
|
|
|
|
|
|
|
|
lastIdx := len(outputList) - 1
|
|
|
|
|
|
|
|
|
|
for i, value := range outputList {
|
|
|
|
|
outputBuf.WriteString(fmt.Sprintf("\n%s%s%s", indent, " ", value))
|
|
|
|
|
if i != lastIdx {
|
|
|
|
|
outputBuf.WriteString(",")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
outputBuf.WriteString(fmt.Sprintf("\n%s]", indent))
|
|
|
|
|
return strings.TrimPrefix(outputBuf.String(), "\n")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func formatListOutput(indent, outputName string, outputList []interface{}) string {
|
|
|
|
|
keyIndent := ""
|
|
|
|
|
|
|
|
|
|
outputBuf := new(bytes.Buffer)
|
|
|
|
|
|
|
|
|
|
if outputName != "" {
|
|
|
|
|
outputBuf.WriteString(fmt.Sprintf("%s%s = [", indent, outputName))
|
|
|
|
|
keyIndent = " "
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lastIdx := len(outputList) - 1
|
|
|
|
|
|
|
|
|
|
for i, value := range outputList {
|
|
|
|
|
switch typedValue := value.(type) {
|
|
|
|
|
case string:
|
|
|
|
|
outputBuf.WriteString(fmt.Sprintf("\n%s%s%s", indent, keyIndent, value))
|
|
|
|
|
case []interface{}:
|
|
|
|
|
outputBuf.WriteString(fmt.Sprintf("\n%s%s", indent,
|
|
|
|
|
formatNestedList(indent+keyIndent, typedValue)))
|
|
|
|
|
case map[string]interface{}:
|
|
|
|
|
outputBuf.WriteString(fmt.Sprintf("\n%s%s", indent,
|
|
|
|
|
formatNestedMap(indent+keyIndent, typedValue)))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if lastIdx != i {
|
|
|
|
|
outputBuf.WriteString(",")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if outputName != "" {
|
|
|
|
|
if len(outputList) > 0 {
|
|
|
|
|
outputBuf.WriteString(fmt.Sprintf("\n%s]", indent))
|
|
|
|
|
} else {
|
|
|
|
|
outputBuf.WriteString("]")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return strings.TrimPrefix(outputBuf.String(), "\n")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func formatNestedMap(indent string, outputMap map[string]interface{}) string {
|
|
|
|
|
ks := make([]string, 0, len(outputMap))
|
|
|
|
|
for k := range outputMap {
|
|
|
|
|
ks = append(ks, k)
|
|
|
|
|
}
|
|
|
|
|
sort.Strings(ks)
|
|
|
|
|
|
|
|
|
|
outputBuf := new(bytes.Buffer)
|
|
|
|
|
outputBuf.WriteString(fmt.Sprintf("%s{", indent))
|
|
|
|
|
|
|
|
|
|
lastIdx := len(outputMap) - 1
|
|
|
|
|
for i, k := range ks {
|
|
|
|
|
v := outputMap[k]
|
|
|
|
|
outputBuf.WriteString(fmt.Sprintf("\n%s%s = %v", indent+" ", k, v))
|
|
|
|
|
|
|
|
|
|
if lastIdx != i {
|
|
|
|
|
outputBuf.WriteString(",")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
outputBuf.WriteString(fmt.Sprintf("\n%s}", indent))
|
|
|
|
|
|
|
|
|
|
return strings.TrimPrefix(outputBuf.String(), "\n")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func formatMapOutput(indent, outputName string, outputMap map[string]interface{}) string {
|
|
|
|
|
ks := make([]string, 0, len(outputMap))
|
|
|
|
|
for k := range outputMap {
|
|
|
|
|
ks = append(ks, k)
|
|
|
|
|
}
|
|
|
|
|
sort.Strings(ks)
|
|
|
|
|
|
|
|
|
|
keyIndent := ""
|
|
|
|
|
|
|
|
|
|
outputBuf := new(bytes.Buffer)
|
|
|
|
|
if outputName != "" {
|
|
|
|
|
outputBuf.WriteString(fmt.Sprintf("%s%s = {", indent, outputName))
|
|
|
|
|
keyIndent = " "
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, k := range ks {
|
|
|
|
|
v := outputMap[k]
|
|
|
|
|
outputBuf.WriteString(fmt.Sprintf("\n%s%s%s = %v", indent, keyIndent, k, v))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if outputName != "" {
|
|
|
|
|
if len(outputMap) > 0 {
|
|
|
|
|
outputBuf.WriteString(fmt.Sprintf("\n%s}", indent))
|
|
|
|
|
} else {
|
|
|
|
|
outputBuf.WriteString("}")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return strings.TrimPrefix(outputBuf.String(), "\n")
|
|
|
|
|
}
|
|
|
|
|
|