MCPcopy
hub / github.com/databus23/helm-diff / generateReport

Function generateReport

diff/diff.go:69–116  ·  view source on GitHub ↗
(oldIndex, newIndex map[string]*manifest.MappingResult, newOwnedReleases map[string]OwnershipDiff, options *Options)

Source from the content-addressed store, hash-verified

67}
68
69func generateReport(oldIndex, newIndex map[string]*manifest.MappingResult, newOwnedReleases map[string]OwnershipDiff, options *Options) (bool, *Report, error) {
70 report := Report{findRenames: options.FindRenames}
71 report.setupReportFormat(options.OutputFormat)
72 var possiblyRemoved []string
73
74 for name, diff := range newOwnedReleases {
75 diff := diffStrings(diff.OldRelease, diff.NewRelease, true)
76 report.addEntry(name, options.SuppressedKinds, "", 0, diff, "OWNERSHIP", nil)
77 }
78
79 for _, key := range sortedKeys(oldIndex) {
80 oldContent := oldIndex[key]
81
82 if newContent, ok := newIndex[key]; ok {
83 // modified?
84 doDiff(&report, key, oldContent, newContent, options)
85 } else {
86 possiblyRemoved = append(possiblyRemoved, key)
87 }
88 }
89
90 var possiblyAdded []string
91 for _, key := range sortedKeys(newIndex) {
92 if _, ok := oldIndex[key]; !ok {
93 possiblyAdded = append(possiblyAdded, key)
94 }
95 }
96
97 removed, added := contentSearch(&report, possiblyRemoved, oldIndex, possiblyAdded, newIndex, options)
98
99 for _, key := range removed {
100 oldContent := oldIndex[key]
101 if oldContent.ResourcePolicy != "keep" {
102 doDiff(&report, key, oldContent, nil, options)
103 }
104 }
105
106 for _, key := range added {
107 newContent := newIndex[key]
108 doDiff(&report, key, nil, newContent, options)
109 }
110
111 seenAnyChanges := len(report.Entries) > 0
112
113 report, err := doSuppress(report, options.SuppressedOutputLineRegex)
114
115 return seenAnyChanges, &report, err
116}
117
118func doSuppress(report Report, suppressedOutputLineRegex []string) (Report, error) {
119 if len(report.Entries) == 0 || len(suppressedOutputLineRegex) == 0 {

Callers 2

ManifestsOwnershipFunction · 0.85
ManifestReportFunction · 0.85

Calls 7

setupReportFormatMethod · 0.95
addEntryMethod · 0.95
diffStringsFunction · 0.85
sortedKeysFunction · 0.85
doDiffFunction · 0.85
contentSearchFunction · 0.85
doSuppressFunction · 0.85

Tested by

no test coverage detected