80 lines
2.8 KiB
PowerShell
80 lines
2.8 KiB
PowerShell
function Test-IsPackageReliableServiceV2 {
|
|
<#
|
|
.SYNOPSIS
|
|
Returns true if the given package is a Service Fabric Reliable Service.
|
|
A Reliable Service is a class library that implements Service Fabric's reliable service pattern, as opposed to a topshelf application.
|
|
If a package ships with Service Fabric Application/Service manifests it is assumed to be a reliable service.
|
|
|
|
.PARAMETER FeedSource
|
|
[string] Source feed used to look up the package by
|
|
|
|
.PARAMETER Name
|
|
[string] Package name to lookup
|
|
|
|
.PARAMETER Version
|
|
[string] Package version to lookup
|
|
|
|
.PARAMETER PackageFiles
|
|
[object[]] List of packages from the Proget results
|
|
Array of objects have the shape: @{ fullpath=; parentFullPath=; name=; isDirectory; }
|
|
|
|
.PARAMETER Credential
|
|
[PSCredential] Credential used for talking to feeds as needed
|
|
#>
|
|
[CmdletBinding(DefaultParameterSetName='RawArgs')]
|
|
Param(
|
|
[Parameter(Mandatory = $true, ParameterSetName = 'RawArgs')]
|
|
[string]$FeedSource,
|
|
[Parameter(Mandatory = $true, ParameterSetName = 'RawArgs')]
|
|
[string]$Name,
|
|
[Parameter(Mandatory = $true, ParameterSetName = 'RawArgs')]
|
|
[string]$Version,
|
|
|
|
[Parameter(Mandatory=$true, ParameterSetName='ProvidedPackageFiles')]
|
|
[object]$PackageFiles,
|
|
|
|
[object]$Package,
|
|
|
|
[Parameter(Mandatory = $false)]
|
|
[PSCredential]$Credential = $null
|
|
)
|
|
|
|
$loglead = (Get-LogLeadName)
|
|
|
|
if ($PSCmdlet.ParameterSetName -eq 'RawArgs') {
|
|
$Package = @{
|
|
Feed = @{
|
|
Source = $FeedSource
|
|
}
|
|
Name = $Name
|
|
Version = $Version
|
|
}
|
|
} else {
|
|
$Name = $Package.Name
|
|
$Version = $Package.Version
|
|
}
|
|
|
|
if($PSCmdlet.ParameterSetName -ne 'ProvidedPackageFiles') {
|
|
$PackageFiles = Get-PackageFileListV2 -Package $Package -Credential $Credential
|
|
}
|
|
|
|
# Consider the package a reliable service if it contains both an application and a service manifest.
|
|
# Search for these two files in known locations.
|
|
|
|
$applicationManifestPattern = 'ApplicationManifest.xml'
|
|
$serviceManifestPattern = 'svc/ServiceManifest.xml'
|
|
|
|
# Are there any files that match the path pattern
|
|
# The closest Linq .Any() match is .Count -gt 0, so we do that
|
|
$hasApplicationManifest = (@($PackageFiles.fullPath -like $applicationManifestPattern).Where({$_}).Count -gt 0)
|
|
$hasServiceManifest = (@($PackageFiles.fullPath -like $serviceManifestPattern).Where({$_}).Count -gt 0)
|
|
|
|
# Consider the package a reliable service if it contains the application/service manifests.
|
|
$isReliableService = $hasApplicationManifest -and $hasServiceManifest;
|
|
|
|
$microText = if($isReliableService) { "is" } else { "is not" };
|
|
Write-Verbose "$loglead : Determined that package $Name|$Version $microText a reliable service";
|
|
|
|
return $isReliableService;
|
|
}
|