@@ -81,7 +81,7 @@ func Manifests(oldIndex, newIndex map[string]*manifest.MappingResult, options *O
81
81
}
82
82
83
83
// ManifestsDiffWithReport diff on manifests
84
- func ManifestsDiffWithReport (oldIndex , newIndex map [string ]* manifest.MappingResult , options * Options , to io.Writer ) Report {
84
+ func ManifestsDiffWithReport (oldIndex , newIndex map [string ]* manifest.MappingResult , options * Options , to io.Writer ) ParsedReport {
85
85
report := Report {}
86
86
report .setupReportFormat (options .OutputFormat )
87
87
var possiblyRemoved []string
@@ -124,26 +124,54 @@ func ManifestsDiffWithReport(oldIndex, newIndex map[string]*manifest.MappingResu
124
124
}
125
125
126
126
report .print (to )
127
- report = filterReportsWithNonZeroDelta (report )
128
- return report
127
+ parsedReport : = filterReportsWithNonZeroDelta (report )
128
+ return parsedReport
129
129
}
130
130
131
- func filterReportsWithNonZeroDelta (report Report ) Report {
132
- var filteredEntries []ReportEntry
131
+ func filterReportsWithNonZeroDelta (report Report ) ParsedReport {
132
+ var parsedEntries []ParsedEntry
133
133
for _ , entry := range report .entries {
134
- var filteredDiffs []difflib. DiffRecord
134
+ var parsedDiffs []ParsedDiff
135
135
for _ , diff := range entry .diffs {
136
136
if diff .Delta != 0 {
137
- filteredDiffs = append (filteredDiffs , diff )
137
+ parsedDiffs = append (parsedDiffs , ParsedDiff {
138
+ Payload : diff .Payload ,
139
+ Delta : int (diff .Delta ),
140
+ })
138
141
}
139
142
}
140
- if len (filteredDiffs ) > 0 {
141
- entry .diffs = filteredDiffs
142
- filteredEntries = append (filteredEntries , entry )
143
- }
143
+ parsedEntries = append (parsedEntries , ParsedEntry {
144
+ Key : entry .key ,
145
+ Kind : entry .kind ,
146
+ Context : entry .context ,
147
+ Diffs : parsedDiffs ,
148
+ ChangeType : entry .changeType ,
149
+ })
144
150
}
145
- report .entries = filteredEntries
146
- return report
151
+
152
+ return ParsedReport {Entries : parsedEntries }
153
+
154
+ }
155
+
156
+ // ParsedReport represents the parsed and organized report
157
+ type ParsedReport struct {
158
+ Entries []ParsedEntry `json:"entries"`
159
+ }
160
+
161
+ // ParsedEntry represents a single entry in the parsed report
162
+ type ParsedEntry struct {
163
+ Key string `json:"key"`
164
+ ReleaseName string `json:"releaseName"`
165
+ Kind string `json:"kind"`
166
+ Context int `json:"context"`
167
+ Diffs []ParsedDiff `json:"diffs"`
168
+ ChangeType string `json:"changeType"`
169
+ }
170
+
171
+ // ParsedDiff represents a single diff in a parsed entry
172
+ type ParsedDiff struct {
173
+ Payload string `json:"payload"`
174
+ Delta int `json:"delta"`
147
175
}
148
176
149
177
func doSuppress (report Report , suppressedOutputLineRegex []string ) (Report , error ) {
0 commit comments