@@ -18,6 +18,7 @@ package typed
18
18
19
19
import (
20
20
"fmt"
21
+ "strings"
21
22
"sync"
22
23
23
24
"sigs.k8s.io/structured-merge-diff/fieldpath"
@@ -116,7 +117,7 @@ func (tv TypedValue) Compare(rhs *TypedValue) (c *Comparison, err error) {
116
117
Modified : fieldpath .NewSet (),
117
118
Added : fieldpath .NewSet (),
118
119
}
119
- c . Merged , err = merge (& tv , rhs , func (w * mergingWalker ) {
120
+ _ , err = merge (& tv , rhs , func (w * mergingWalker ) {
120
121
if w .lhs == nil {
121
122
c .Added .Insert (w .path )
122
123
} else if w .rhs == nil {
@@ -126,8 +127,6 @@ func (tv TypedValue) Compare(rhs *TypedValue) (c *Comparison, err error) {
126
127
// Need to implement equality check on the value type.
127
128
c .Modified .Insert (w .path )
128
129
}
129
-
130
- ruleKeepRHS (w )
131
130
}, func (w * mergingWalker ) {
132
131
if w .lhs == nil {
133
132
c .Added .Insert (w .path )
@@ -268,10 +267,6 @@ func merge(lhs, rhs *TypedValue, rule, postRule mergeRule) (*TypedValue, error)
268
267
// No field will appear in more than one of the three fieldsets. If all of the
269
268
// fieldsets are empty, then the objects must have been equal.
270
269
type Comparison struct {
271
- // Merged is the result of merging the two objects, as explained in the
272
- // comments on TypedValue.Merge().
273
- Merged * TypedValue
274
-
275
270
// Removed contains any fields removed by rhs (the right-hand-side
276
271
// object in the comparison).
277
272
Removed * fieldpath.Set
@@ -289,15 +284,15 @@ func (c *Comparison) IsSame() bool {
289
284
290
285
// String returns a human readable version of the comparison.
291
286
func (c * Comparison ) String () string {
292
- str := fmt . Sprintf ( "- Merged Object: \n %v \n " , c . Merged . AsValue ())
287
+ bld := strings. Builder {}
293
288
if ! c .Modified .Empty () {
294
- str += fmt .Sprintf ("- Modified Fields:\n %v\n " , c .Modified )
289
+ bld . WriteString ( fmt .Sprintf ("- Modified Fields:\n %v\n " , c .Modified ) )
295
290
}
296
291
if ! c .Added .Empty () {
297
- str += fmt .Sprintf ("- Added Fields:\n %v\n " , c .Added )
292
+ bld . WriteString ( fmt .Sprintf ("- Added Fields:\n %v\n " , c .Added ) )
298
293
}
299
294
if ! c .Removed .Empty () {
300
- str += fmt .Sprintf ("- Removed Fields:\n %v\n " , c .Removed )
295
+ bld . WriteString ( fmt .Sprintf ("- Removed Fields:\n %v\n " , c .Removed ) )
301
296
}
302
- return str
297
+ return bld . String ()
303
298
}
0 commit comments