src/public/Resolve-PackageSource.ps1

# This function gets called during find-package, install-package, get-packagesource etc.
# OneGet uses this method to identify which provider can handle the packages from a particular source location.
function Resolve-PackageSource {

    Write-Debug ($LocalizedData.ProviderDebugMessage -f ('Resolve-PackageSource'))

    $SourceNames = $request.PackageSources

    # No source name pattern specified, so return everything
    if (-not $SourceNames) {
        $SourceNames = "*"
    }

    # Get sources from Chocolatey
    [array]$RegisteredPackageSources = Get-PackageSources

    # Filter sources by whether they're disabled in Chocolatey
    $RegisteredPackageSources | Where-Object {
        $src = $_.Name
        Write-Debug "Source $src is registred"
        # Pass the source on only if it matches the provided name pattern
        $SourceNames | Where-Object { $src -like $_ }
    } | ForEach-Object {
        New-PackageSource -Name $_.Name -Location $_.Location -Trusted $true -Registered $true
    }
}