(key, changeType, kind string, suppressedKinds []string, oldContent, newContent *manifest.MappingResult)
| 43 | } |
| 44 | |
| 45 | func 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 | |
| 83 | func manifestExists(m *manifest.MappingResult) bool { |
| 84 | return m != nil && strings.TrimSpace(m.Content) != "" |
no test coverage detected