ps/Modules/Alkami.DevOps.Installation/Public/New-DummyPackageInstallationData.ps1
2023-05-30 22:51:22 -07:00

127 lines
3.8 KiB
PowerShell

function New-DummyPackageInstallationData {
<#
.SYNOPSIS
Create a new PackageMetadata object for unit tests. Utilized by Classify-Packages tests.
.PARAMETER PackageName
Name of the package being created.
.PARAMETER PackageVersion
Version of the package being created.
.PARAMETER IsWebOnly
Indicates that the package is only installed on Web servers.
.PARAMETER IsAppOnly
Indicates that the package is only installed on App servers.
.PARAMETER IsMicOnly
Indicates that the package is only installed on Mic servers.
.PARAMETER IsFullScale
Indicates that the package is only installed everywhere.
.PARAMETER IsHotFix
Indicates that the package is a Hotfix package.
#>
[CmdletBinding()]
Param (
[Parameter(Mandatory = $true, ParameterSetName = "FullScale")]
[Parameter(Mandatory = $true, ParameterSetName = "Web")]
[Parameter(Mandatory = $true, ParameterSetName = "App")]
[Parameter(Mandatory = $true, ParameterSetName = "Mic")]
[string]$PackageName,
[Parameter(Mandatory = $true, ParameterSetName = "FullScale")]
[Parameter(Mandatory = $true, ParameterSetName = "Web")]
[Parameter(Mandatory = $true, ParameterSetName = "App")]
[Parameter(Mandatory = $true, ParameterSetName = "Mic")]
[string]$PackageVersion,
[Parameter(Mandatory = $true, ParameterSetName = "Web")]
[switch]$IsWebOnly,
[Parameter(Mandatory = $true, ParameterSetName = "App")]
[switch]$IsAppOnly,
[Parameter(Mandatory = $true, ParameterSetName = "Mic")]
[switch]$IsMicOnly,
[Parameter(Mandatory = $true, ParameterSetName = "FullScale")]
[switch]$IsFullScale,
[Parameter(Mandatory = $false)]
[switch]$IsHotfix,
[bool]$IsValid = $true
)
$tags = @()
$tier = 2
$installToWeb = $false
$installToApp = $false
$installToMic = $false
if ($IsWebOnly) {
$tags = @(
"ORB",
"Widget"
)
$installToWeb = $true
}
if ($IsAppOnly) {
$tags = @(
"ORB",
"Generic",
"SSO",
"Provider"
)
$installToApp = $true
}
if ($IsFullScale) {
$tags = @(
"Service",
"Infrastructure"
)
$installToWeb = $true
$installToApp = $true
$installToMic = $true
$tier = 0
}
if ($IsMicOnly) {
$tags = @(
"Service",
"Provider"
)
$installToMic = $true
}
$objectTemplate = @{
Tags = $tags
Name = $PackageName
IsReliableService = $false
Version = $PackageVersion
HasInfrastructureMigration = $false
Upgrade = $false
IsService = $IsService -or $IsFullScale
InstallToAppTier = $installToApp
InstallToMicTier = $installToMic
InstallToWebTier = $installToWeb
IsMicroservice = $IsService -or $IsFullScale
IsFullScaleMicroservice = $IsFullScale
ForceSameVersion = $true
PreventRollback = $false
IsDbms = $false
Feed = @{
Name = "imaginaryfeed"
Source = "https://imaginaryfeed/nuget/feed"
IsDefault = $false
Priority = "0"
Disabled = $false
IsSDK = $false
}
IsInstaller = $false
IsInfrastructure = $IsFullScale
StartMode = $null
NewRelicAppName = $null
IsSDK = $false
IsValid = $IsValid
IsHotfix = $IsHotfix
InstallToWeb = $installToWeb
InstallToFab = $false
InstallToMic = $installToMic
InstallToApp = $installToApp
HasAlkamiManifest = $true
Tier = $tier
}
return (New-Object -TypeName PSObject -Prop $objectTemplate)
}