@@ -142,9 +142,9 @@ var tr = i18n.Tr
142
142
143
143
// MergeIntoPackages converts the Index data into a cores.Packages and merge them
144
144
// with the existing contents of the cores.Packages passed as parameter.
145
- func (index Index ) MergeIntoPackages (outPackages cores.Packages ) {
145
+ func (index Index ) MergeIntoPackages (outPackages cores.Packages , mutators ... cores. PackageMutator ) {
146
146
for _ , inPackage := range index .Packages {
147
- inPackage .extractPackageIn (outPackages , index .IsTrusted )
147
+ inPackage .extractPackageIn (outPackages , index .IsTrusted , mutators ... )
148
148
}
149
149
}
150
150
@@ -243,7 +243,7 @@ func IndexFromPlatformRelease(pr *cores.PlatformRelease) Index {
243
243
}
244
244
}
245
245
246
- func (inPackage indexPackage ) extractPackageIn (outPackages cores.Packages , trusted bool ) {
246
+ func (inPackage indexPackage ) extractPackageIn (outPackages cores.Packages , trusted bool , mutators ... cores. PackageMutator ) {
247
247
outPackage := outPackages .GetOrCreatePackage (inPackage .Name )
248
248
outPackage .Maintainer = inPackage .Maintainer
249
249
outPackage .WebsiteURL = inPackage .WebsiteURL
@@ -258,6 +258,12 @@ func (inPackage indexPackage) extractPackageIn(outPackages cores.Packages, trust
258
258
for _ , inPlatform := range inPackage .Platforms {
259
259
inPlatform .extractPlatformIn (outPackage , trusted )
260
260
}
261
+
262
+ // Apply mutations in case we need to override the above behaviour. For example this is used to change the `indexed`
263
+ // property when the `LoadPackageIndexFromFile` or `LoadPackageIndex` func is loading the global index files.
264
+ for _ , mutator := range mutators {
265
+ mutator (outPackage )
266
+ }
261
267
}
262
268
263
269
func (inPlatformRelease indexPlatformRelease ) extractPlatformIn (outPackage * cores.Package , trusted bool ) error {
0 commit comments