MCPcopy Index your code
hub / github.com/databus23/helm-diff / buildStructuredEntry

Function buildStructuredEntry

diff/structured.go:45–81  ·  view source on GitHub ↗
(key, changeType, kind string, suppressedKinds []string, oldContent, newContent *manifest.MappingResult)

Source from the content-addressed store, hash-verified

43}
44
45func buildStructuredEntry(key, changeType, kind string, suppressedKinds []string, oldContent, newContent *manifest.MappingResult) (*StructuredEntry, error) {
46 entry := &StructuredEntry{
47 ChangeType: changeType,
48 ResourceStatus: ResourceStatus{
49 OldExists: manifestExists(oldContent),
50 NewExists: manifestExists(newContent),
51 },
52 }
53
54 isSuppressed := containsKind(suppressedKinds, kind)
55 entry.ChangesSuppressed = isSuppressed
56
57 oldJSON, oldObj, err := manifestToJSON(oldContent)
58 if err != nil {
59 return nil, fmt.Errorf("convert old manifest: %w", err)
60 }
61 newJSON, newObj, err := manifestToJSON(newContent)
62 if err != nil {
63 return nil, fmt.Errorf("convert new manifest: %w", err)
64 }
65
66 entry.populateMetadata(key, oldObj, newObj)
67
68 if isSuppressed {
69 return entry, nil
70 }
71
72 if changeType == "MODIFY" && oldJSON != nil && newJSON != nil {
73 changes, err := calculateFieldChanges(oldJSON, newJSON)
74 if err != nil {
75 return nil, err
76 }
77 entry.Changes = changes
78 }
79
80 return entry, nil
81}
82
83func manifestExists(m *manifest.MappingResult) bool {
84 return m != nil && strings.TrimSpace(m.Content) != ""

Callers 1

doDiffFunction · 0.85

Calls 5

populateMetadataMethod · 0.95
manifestExistsFunction · 0.85
containsKindFunction · 0.85
manifestToJSONFunction · 0.85
calculateFieldChangesFunction · 0.85

Tested by

no test coverage detected