Use named parameter arguments and explicitly set switch argument values (#3171)

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
This commit is contained in:
Azure SDK Bot 2021-12-08 16:42:51 -08:00 committed by GitHub
parent ccb435daa8
commit 8e66a46e71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 7 deletions

View File

@ -9,7 +9,7 @@ class StressTestPackageInfo {
[string]$ReleaseName
}
function FindStressPackages([string]$directory, [hashtable]$filters = @{}, [boolean]$CI = $false) {
function FindStressPackages([string]$directory, [hashtable]$filters = @{}, [switch]$CI) {
# Bare minimum filter for stress tests
$filters['stressTest'] = 'true'
@ -18,7 +18,7 @@ function FindStressPackages([string]$directory, [hashtable]$filters = @{}, [bool
foreach ($chartFile in $chartFiles) {
$chart = ParseChart $chartFile
if (matchesAnnotations $chart $filters) {
$packages += NewStressTestPackageInfo $chart $chartFile $CI
$packages += NewStressTestPackageInfo -chart $chart -chartFile $chartFile -CI:$CI
}
}
@ -39,7 +39,7 @@ function MatchesAnnotations([hashtable]$chart, [hashtable]$filters) {
return $true
}
function NewStressTestPackageInfo([hashtable]$chart, [System.IO.FileInfo]$chartFile, [boolean]$CI) {
function NewStressTestPackageInfo([hashtable]$chart, [System.IO.FileInfo]$chartFile, [switch]$CI) {
$namespace = if ($CI) {
$chart.annotations.namespace
} else {

View File

@ -63,7 +63,7 @@ function DeployStressTests(
[string]$deployId = 'local',
[switch]$login,
[string]$subscription = '',
[switch]$ci
[switch]$CI
) {
if ($environment -eq 'test') {
if ($clusterGroup -or $subscription) {
@ -89,19 +89,25 @@ function DeployStressTests(
if (!$clusterGroup -or !$subscription) {
throw "clusterGroup and subscription parameters must be specified when logging into an environment that is not test or prod."
}
Login $subscription $clusterGroup $pushImages
Login -subscription $subscription -clusterGroup $clusterGroup -pushImages:$pushImages
}
RunOrExitOnFailure helm repo add stress-test-charts https://stresstestcharts.blob.core.windows.net/helm/
Run helm repo update
if ($LASTEXITCODE) { return $LASTEXITCODE }
$pkgs = FindStressPackages $searchDirectory $filters $CI
$pkgs = FindStressPackages -directory $searchDirectory -filters $filters -CI:$CI
Write-Host "" "Found $($pkgs.Length) stress test packages:"
Write-Host $pkgs.Directory ""
foreach ($pkg in $pkgs) {
Write-Host "Deploying stress test at '$($pkg.Directory)'"
DeployStressPackage $pkg $deployId $environment $repository $pushImages $login
DeployStressPackage `
-pkg $pkg `
-deployId $deployId `
-environment $environment `
-repositoryBase $repository `
-pushImages:$pushImages `
-login:$login
}
Write-Host "Releases deployed by $deployId"