Pipelines/Steps/Install/OnPrem/Solr/Add-RebuildCoresConfig.ps1

$ErrorActionPreference = "Stop"

Write-Output "Add Solr rebuild cores config started..."

if (($null -eq $SAFConfiguration.search.solr.rebuildCores) -or ($SAFConfiguration.search.solr.rebuildCores.Count -lt 1)) {
    Write-Output "No rebuild cores defined. Skipping..."
}
else {
    $rebuildCores = @()
    foreach ($rebuildCore in $SAFConfiguration.search.solr.rebuildCores) {
        $fullOriginalCoreName = "$($SAFConfiguration.prefix)_$($rebuildCore.mainCore)"
        $rebuildCores += [PSCustomObject]@{    
            indexName = $rebuildCore.indexName
            mainName  = $fullOriginalCoreName
        }
    }
    
    $sitecoreDir = $SAFConfiguration.sitecore.installDir
    AddSolrRebuildCoresConfig -SitecoreDir "$sitecoreDir" -RebuildCores $rebuildCores 
}

Write-Output "Add Solr rebuild cores config done."