< Summary - Kestrun — Combined Coverage

Information
Class: Private.Server.Resolve-KestrunServer
Assembly: Kestrun.PowerShell.Private
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Private/Server/Resolve-KestrunServer.ps1
Tag: Kestrun/Kestrun@2d87023b37eb91155071c91dd3d6a2eeb3004705
Line coverage
0%
Covered lines: 0
Uncovered lines: 8
Coverable lines: 8
Total lines: 43
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 09/04/2025 - 22:37:32 Line coverage: 80% (4/5) Total lines: 35 Tag: Kestrun/Kestrun@afb7aadc0a8a42bfa2b51ea62c8a6e2cf63faec610/13/2025 - 16:52:37 Line coverage: 0% (0/8) Total lines: 43 Tag: Kestrun/Kestrun@10d476bee71c71ad215bb8ab59f219887b5b4a5e

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Private/Server/Resolve-KestrunServer.ps1

#LineLine coverage
 1
 2<#
 3.SYNOPSIS
 4    Resolves a Kestrun server instance from the provided input.
 5
 6.DESCRIPTION
 7    The Resolve-KestrunServer function checks if the provided server instance is valid.
 8    If not, it attempts to retrieve the default Kestrun server instance.
 9
 10.PARAMETER Server
 11    The Kestrun server instance to resolve.
 12
 13.EXAMPLE
 14    $resolvedServer = Resolve-KestrunServer -Server $myServer
 15    This will resolve $myServer to a valid Kestrun server instance.
 16
 17.NOTES
 18    If no server is provided, the function will look for the default Kestrun server instance
 19    managed by KestrunHostManager.  If no default instance exists, an error is thrown.
 20    Used inside kestrun cmdlets to ensure a valid server instance is available for operations
 21    as:  $Server = Resolve-KestrunServer -Server $Server
 22#>
 23function Resolve-KestrunServer {
 24    param (
 25        [Kestrun.Hosting.KestrunHost]$Server
 26    )
 027    if ($null -eq $Server) {
 028        if ($null -ne $KrServer) {
 029            Write-KrLog -Level Verbose -Message "No server specified, using global `$KrServer variable."
 30            # If no server is specified, use the global $KrServer variable
 31            # This is useful for scripts that run in the context of a Kestrun server
 032            $Server = $KrServer
 33        } else {
 34            # Try to get the default Kestrun server instance
 035            $Server = [Kestrun.KestrunHostManager]::Default
 36        }
 037        if ($null -eq $Server) {
 038            throw 'No Kestrun server instance found. Please create a Kestrun server instance.'
 39        }
 40    }
 041    return $Server
 42}
 43

Methods/Properties

Resolve-KestrunServer()