@@ -142,9 +142,9 @@ var tr = i18n.Tr
142142
143143// MergeIntoPackages converts the Index data into a cores.Packages and merge them
144144// 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 ) {
146146 for _ , inPackage := range index .Packages {
147- inPackage .extractPackageIn (outPackages , index .IsTrusted )
147+ inPackage .extractPackageIn (outPackages , index .IsTrusted , mutators ... )
148148 }
149149}
150150
@@ -243,7 +243,7 @@ func IndexFromPlatformRelease(pr *cores.PlatformRelease) Index {
243243 }
244244}
245245
246- func (inPackage indexPackage ) extractPackageIn (outPackages cores.Packages , trusted bool ) {
246+ func (inPackage indexPackage ) extractPackageIn (outPackages cores.Packages , trusted bool , mutators ... cores. PackageMutator ) {
247247 outPackage := outPackages .GetOrCreatePackage (inPackage .Name )
248248 outPackage .Maintainer = inPackage .Maintainer
249249 outPackage .WebsiteURL = inPackage .WebsiteURL
@@ -258,6 +258,12 @@ func (inPackage indexPackage) extractPackageIn(outPackages cores.Packages, trust
258258 for _ , inPlatform := range inPackage .Platforms {
259259 inPlatform .extractPlatformIn (outPackage , trusted )
260260 }
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+ }
261267}
262268
263269func (inPlatformRelease indexPlatformRelease ) extractPlatformIn (outPackage * cores.Package , trusted bool ) error {
0 commit comments