ps/Modules/Alkami.PowerShell.Choco/Public/Get-ChocolateyParameterString.ps1
2023-05-30 22:51:22 -07:00

59 lines
1.8 KiB
PowerShell

function Get-ChocolateyParameterString {
<#
.SYNOPSIS
Get the complex parameter string that gets passed on package installation to all installable packages.
.DESCRIPTION
Get the complex parameter string that gets passed on package installation to all installable packages.
We pass these values at all times even if the installing package doesn't know about the parameters for consistency.
.PARAMETER Package
[PSObject] Must have a property Name that indicates the package being installed
.PARAMETER Environment
Optional. The environment this package is being installed to.
.PARAMETER RunMigrations
[Switch] If this package has migraitons, should migrations be run for this package at install?
.PARAMETER Package
[Switch] If this is a service, should it be started?
#>
[OutputType([string])]
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[object]$Package,
[Parameter(Mandatory = $false)]
[Alias("env","e")]
[string]$Environment,
[Parameter(Mandatory = $false)]
[Alias("migrate","m")]
[bool]$RunMigrations = $true,
[Parameter(Mandatory = $false)]
[Alias("start","s")]
[bool]$StartService = $false
)
# Determine optional New Relic app name based on the package
$newRelicParam = "";
if ($Environment)
{
$newRelicName = (Get-NewRelicAppNameForConfigurationValue $Package.Name)
$newRelicParam = "/NewRelicAppName:'$Environment $newRelicName'";
}
$boolString = if($RunMigrations) { "true" } else { "false" }
$migrationParam = "/MigrationsEnabled:$boolString"
$boolString = if($StartService) { "true" } else { "false" }
$startupParam = "/Alkami.Installer.ServiceStartupMode:$boolString"
$chocoParamString = "`"$migrationParam $startupParam $newRelicParam`"";
return $chocoParamString;
}