format staticcheck
This commit is contained in:
parent
a1d41504f2
commit
41d4dd82d6
|
@ -620,7 +620,6 @@ func (p *blockBodyDiffPrinter) writeSensitiveNestedBlockDiff(name string, old, n
|
||||||
p.buf.WriteRune('\n')
|
p.buf.WriteRune('\n')
|
||||||
p.buf.WriteString(strings.Repeat(" ", indent+2))
|
p.buf.WriteString(strings.Repeat(" ", indent+2))
|
||||||
p.buf.WriteString("}")
|
p.buf.WriteString("}")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *blockBodyDiffPrinter) writeNestedBlockDiff(name string, label *string, blockS *configschema.Block, action plans.Action, old, new cty.Value, indent int, path cty.Path) bool {
|
func (p *blockBodyDiffPrinter) writeNestedBlockDiff(name string, label *string, blockS *configschema.Block, action plans.Action, old, new cty.Value, indent int, path cty.Path) bool {
|
||||||
|
@ -878,7 +877,7 @@ func (p *blockBodyDiffPrinter) writeValueDiff(old, new cty.Value, indent int, pa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Index(oldS, "\n") < 0 && strings.Index(newS, "\n") < 0 {
|
if !strings.Contains(oldS, "\n") && !strings.Contains(newS, "\n") {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1053,7 +1052,6 @@ func (p *blockBodyDiffPrinter) writeValueDiff(old, new cty.Value, indent int, pa
|
||||||
if hidden > 0 && i < len(elemDiffs) {
|
if hidden > 0 && i < len(elemDiffs) {
|
||||||
hidden--
|
hidden--
|
||||||
nextContextDiff = suppressedElements[hidden]
|
nextContextDiff = suppressedElements[hidden]
|
||||||
suppressedElements = suppressedElements[:hidden]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are still hidden elements, show an elision
|
// If there are still hidden elements, show an elision
|
||||||
|
|
|
@ -213,116 +213,3 @@ func formatStateModule(p blockBodyDiffPrinter, m *states.Module, schemas *terraf
|
||||||
}
|
}
|
||||||
p.buf.WriteString("\n")
|
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")
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue