ps/Modules/Alkami.PowerShell.Configuration/Public/Set-NewRelicAppName.ps1
2023-05-30 22:51:22 -07:00

48 lines
1.7 KiB
PowerShell

function Set-NewRelicAppName {
<#
.SYNOPSIS
Set enviroment to NewRelic.AppName in web.config
.PARAMETER enviroment
The environment string to use in the app name. For example, "Staging Lane X" will result in a app name in "Staging Lane X NagConfiguration"
.PARAMETER configFiles
An array of configuration files to update. Either this parameter or filePath must be provided
.PARAMETER filePath
The parent path of configuration files. When specified without configFiles, will search for the files to update. Either this parameter
or configFiles must be provided
#>
[CmdletBinding()]
## TODO: cbrand ~ $enviroment is misspelled.
param(
[Parameter(Mandatory = $true)][string]$enviroment,
[string[]]$configFiles,
[string]$filePath
)
$logLead = (Get-LogLeadName)
if (Test-IsCollectionNullOrEmpty $configFiles)
{
if (!([String]::IsNullOrEmpty($filePath)))
{
Write-Host ("$logLead : Looking for Configuration Files in {0}" -f $filePath)
$configFiles = @()
$configFiles += Get-ConfigurationFiles -stagedFilePath $filePath -findTempFiles $true
$configFiles += Get-ConfigurationFiles -stagedFilePath $filePath -findTempFiles $false
}
else
{
## TODO: Make this a parameter set to ensure these values are always passed
Write-Warning "$logLead : No Configuration Files Passed and No Filepath Provided. Execution cannot continue"
return
}
}
foreach ($configFile in $configFiles) {
Set-NewRelicAppNameConfigFileValue -EnvironmentLabel $enviroment -ConfigFilePath $configFile
}
}