MCPcopy Create free account
hub / github.com/aws-cloudformation/rain / formatSub

Function formatSub

cft/diff/format.go:111–147  ·  view source on GitHub ↗
(d Diff, path []interface{}, long bool)

Source from the content-addressed store, hash-verified

109}
110
111func formatSub(d Diff, path []interface{}, long bool) string {
112 // Format the element
113 formatted := formatDiff(d, path, long)
114
115 v, isValue := d.(value)
116 if isValue {
117 k := reflect.ValueOf(v.Value()).Kind()
118
119 if k != reflect.Array && k != reflect.Map && k != reflect.Slice {
120 return fmt.Sprintf(" %s\n", formatted)
121 }
122 }
123
124 // Trim out blank lines
125 parts := make([]string, 0)
126 for _, part := range strings.Split(formatted, "\n") {
127 if strings.TrimSpace(part) != "" {
128 parts = append(parts, part)
129 }
130 }
131
132 output := strings.Builder{}
133
134 output.WriteString("\n")
135 for _, part := range parts {
136 if isValue {
137 part = fmt.Sprintf("%s %s%s", v.Mode(), indent, part)
138 } else {
139 part = part[:len(Added.String())] + indent + part[len(Added.String()):]
140 }
141
142 output.WriteString(part)
143 output.WriteString("\n")
144 }
145
146 return output.String()
147}

Callers 2

formatSliceFunction · 0.85
formatMapFunction · 0.85

Calls 4

formatDiffFunction · 0.85
ValueMethod · 0.65
ModeMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected