Preserve addition / modification / removal counts into the Report (and output in the header, or in brief, or via a new output)
Issue
Currently core.go is well aware of addition / modification / removal counts, during it's operation, but this information is getting lost in the Report, and not outputted in any of the output modes.
It's easier for me to demonstrate with a piece of code that extracts (something like) the information we're looking for
addition, modification, removal := 0, 0, 0
for _, diff := range report.Diffs {
for _, detail := range diff.Details {
if detail.Kind == ADDITION {
addition += len(detail.To.Content)
} else if detail.Kind == REMOVAL {
removal += len(detail.From.Content)
} else if detail.Kind == MODIFICATION {
modification += 1
}
}
}
fmt.Println(fmt.Sprintf("Changes: %d additions, %d modifications, %d removals", addition, modification, removal))
THis piece of code is nesting the additions and removals into a single Diff, so currently if we add 5 new documents, we get back one change detected when in fact 5 additions occurred: https://github.com/homeport/dyff/blob/main/pkg/dyff/core.go#L747-L769
Context
We are using dyff as part of a CI action to compare rendered K8S manifests before/after PR, and the produced diff is by far the best among all the tools we tried. So we are very committed to sticking with dyff.
The diff itself is linked to in GH action output, which is great but we'd like to add a summary in the comment message where we link to GH action run logs.
But currently it's impossible to extract this information, and we'd like to avoid forking if possible.
If these additions / modifications / removals counts could be preserved, and printed in some way, we could use text processing to parse and make it into the format we need. But right now modification of the code is necessary.
Footnote
- Big thanks for creating this tool. There's basically no alternatives to it when it comes to offline comparing K8S manifests.
- I can contribute PR as well, but not sure what's the best way to preserve this information and how to make sure it's accurate, some more reading of the code will be necessary for that, but I wanted to create the issue for discussion.