@@ -52,7 +52,9 @@ func multiVersionDiff(infoDiff []MultiVersionInfo, packageName string, map1, map
52
52
diff1 = append (diff1 , packInfo1 )
53
53
continue
54
54
} else {
55
- if reflect .DeepEqual (packInfo1 , packInfo2 ) {
55
+ // If a package instance is installed in the same place in Image1 and Image2 with the same version,
56
+ // then they are the same package and should not be included in the diff
57
+ if packInfo1 .Version == packInfo2 .Version {
56
58
delete (map2 , path )
57
59
} else {
58
60
diff1 = append (diff1 , packInfo1 )
@@ -127,25 +129,36 @@ func diffMaps(map1, map2 interface{}) interface{} {
127
129
for _ , pack := range map1Value .MapKeys () {
128
130
packageEntry1 := map1Value .MapIndex (pack )
129
131
packageEntry2 := map2Value .MapIndex (pack )
132
+ // If the package does not exist in Image2's map of packages, add it to the collection of unique packages in Image1
130
133
if ! packageEntry2 .IsValid () {
131
134
diff1 .SetMapIndex (pack , packageEntry1 )
132
- } else if ! reflect .DeepEqual (packageEntry2 .Interface (), packageEntry1 .Interface ()) {
135
+ // If the package exists in Image2's map of packages but the package information differs between images, add it to
136
+ // the difference. Otherwise, if the information is consistent across images, delete it from the Image2's map of packages.
137
+ } else {
133
138
if multiV {
134
- multiInfoDiff = multiVersionDiff (multiInfoDiff , pack .String (),
135
- packageEntry1 .Interface ().(map [string ]PackageInfo ), packageEntry2 .Interface ().(map [string ]PackageInfo ))
139
+ if ! reflect .DeepEqual (packageEntry2 .Interface (), packageEntry1 .Interface ()) {
140
+ multiInfoDiff = multiVersionDiff (multiInfoDiff , pack .String (),
141
+ packageEntry1 .Interface ().(map [string ]PackageInfo ),
142
+ packageEntry2 .Interface ().(map [string ]PackageInfo ))
143
+ }
136
144
} else {
137
- infoDiff = append (infoDiff , Info {pack .String (), packageEntry1 .Interface ().(PackageInfo ),
138
- packageEntry2 .Interface ().(PackageInfo )})
145
+ packageInfo1 := packageEntry1 .Interface ().(PackageInfo )
146
+ packageInfo2 := packageEntry2 .Interface ().(PackageInfo )
147
+ // If two instances of the same package don't have the same version, then they are considered to be different
148
+ if packageInfo1 .Version != packageInfo2 .Version {
149
+ infoDiff = append (infoDiff , Info {pack .String (), packageInfo1 , packageInfo2 })
150
+ }
139
151
}
140
152
map2Value .SetMapIndex (pack , reflect.Value {})
141
- } else {
142
- map2Value .SetMapIndex (pack , reflect.Value {})
143
153
}
144
154
}
155
+
156
+ // The packages remaining in Image2's map of images are those that exist uniquely in Image2
145
157
for _ , key2 := range map2Value .MapKeys () {
146
158
packageEntry2 := map2Value .MapIndex (key2 )
147
159
diff2 .SetMapIndex (key2 , packageEntry2 )
148
160
}
161
+
149
162
if multiV {
150
163
return MultiVersionPackageDiff {Packages1 : diff1 .Interface ().(map [string ]map [string ]PackageInfo ),
151
164
Packages2 : diff2 .Interface ().(map [string ]map [string ]PackageInfo ), InfoDiff : multiInfoDiff }
0 commit comments