(r *Report, to io.Writer)
| 82 | } |
| 83 | |
| 84 | func printDyffReport(r *Report, to io.Writer) { |
| 85 | currentFile, _ := os.CreateTemp("", "existing-values") |
| 86 | defer func() { |
| 87 | _ = os.Remove(currentFile.Name()) |
| 88 | }() |
| 89 | newFile, _ := os.CreateTemp("", "new-values") |
| 90 | defer func() { |
| 91 | _ = os.Remove(newFile.Name()) |
| 92 | }() |
| 93 | |
| 94 | for _, entry := range r.Entries { |
| 95 | _, _ = currentFile.WriteString("---\n") |
| 96 | _, _ = newFile.WriteString("---\n") |
| 97 | for _, record := range entry.Diffs { |
| 98 | switch record.Delta { |
| 99 | case difflib.Common: |
| 100 | _, _ = currentFile.WriteString(record.Payload + "\n") |
| 101 | _, _ = newFile.WriteString(record.Payload + "\n") |
| 102 | case difflib.LeftOnly: |
| 103 | _, _ = currentFile.WriteString(record.Payload + "\n") |
| 104 | case difflib.RightOnly: |
| 105 | _, _ = newFile.WriteString(record.Payload + "\n") |
| 106 | } |
| 107 | } |
| 108 | } |
| 109 | _ = currentFile.Close() |
| 110 | _ = newFile.Close() |
| 111 | |
| 112 | currentInputFile, newInputFile, _ := ytbx.LoadFiles(currentFile.Name(), newFile.Name()) |
| 113 | |
| 114 | var compareOptions []dyff.CompareOption |
| 115 | compareOptions = append(compareOptions, |
| 116 | dyff.IgnoreWhitespaceChanges(true), |
| 117 | dyff.KubernetesEntityDetection(true), |
| 118 | ) |
| 119 | if r.findRenames > 0 { |
| 120 | compareOptions = append(compareOptions, dyff.DetectRenames(true)) |
| 121 | } |
| 122 | report, _ := dyff.CompareInputFiles(currentInputFile, newInputFile, compareOptions...) |
| 123 | reportWriter := &dyff.HumanReport{ |
| 124 | Report: report, |
| 125 | OmitHeader: true, |
| 126 | MinorChangeThreshold: 0.1, |
| 127 | } |
| 128 | _ = reportWriter.WriteReport(to) |
| 129 | } |
| 130 | |
| 131 | // addEntry: stores diff changes. |
| 132 | func (r *Report) addEntry(key string, suppressedKinds []string, kind string, context int, diffs []difflib.DiffRecord, changeType string, structured *StructuredEntry) { |
no outgoing calls