From 0b6b64984298db1b0ac0627ae8220c4467880fa9 Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Fri, 5 May 2023 15:03:53 -0400 Subject: [PATCH] Swap defaults: -Login and -PushImages to -SkipLogin and -SkipPushImages --- .../stress-testing/deploy-stress-tests.ps1 | 8 +++--- .../stress-test-deployment-lib.ps1 | 26 +++++++++---------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/eng/common/scripts/stress-testing/deploy-stress-tests.ps1 b/eng/common/scripts/stress-testing/deploy-stress-tests.ps1 index bc028f26aa..8abaa40d0c 100644 --- a/eng/common/scripts/stress-testing/deploy-stress-tests.ps1 +++ b/eng/common/scripts/stress-testing/deploy-stress-tests.ps1 @@ -1,16 +1,14 @@ -# Set a default parameter set here so we can call this script without requiring -Login and -Subscription, -# but if it IS called with either of those, then both parameters need to be required. Not defining a -# default parameter set makes Login/Subscription required all the time. +# Not defining a default parameter set makes SkipLogin/Subscription required all the time. [CmdletBinding(DefaultParameterSetName = 'Default')] param( [string]$SearchDirectory, [hashtable]$Filters, [string]$Environment, [string]$Repository, - [switch]$PushImages, + [switch]$SkipPushImages, [string]$ClusterGroup, [string]$DeployId, - [switch]$Login, + [switch]$SkipLogin, [string]$Subscription, # Default to true in Azure Pipelines environments diff --git a/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 b/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 index 5ad163c6a8..f8763de350 100644 --- a/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 +++ b/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 @@ -43,7 +43,7 @@ function RunOrExitOnFailure() } } -function Login([string]$subscription, [string]$clusterGroup, [switch]$pushImages) +function Login([string]$subscription, [string]$clusterGroup, [switch]$skipPushImages) { Write-Host "Logging in to subscription, cluster and container registry" az account show *> $null @@ -73,7 +73,7 @@ function Login([string]$subscription, [string]$clusterGroup, [switch]$pushImages RunOrExitOnFailure kubectl config set-context $clusterName --namespace $defaultNamespace } - if ($pushImages) { + if (!$skipPushImages) { $registry = RunOrExitOnFailure az acr list -g $clusterGroup --subscription $subscription -o json $registryName = ($registry | ConvertFrom-Json).name RunOrExitOnFailure az acr login -n $registryName @@ -86,10 +86,10 @@ function DeployStressTests( # Default to playground environment [string]$environment = 'pg', [string]$repository = '', - [switch]$pushImages, + [switch]$skipPushImages, [string]$clusterGroup = '', [string]$deployId = '', - [switch]$login, + [switch]$skipLogin, [string]$subscription = '', [switch]$CI, [string]$Namespace, @@ -125,8 +125,8 @@ function DeployStressTests( throw "clusterGroup and subscription parameters must be specified when deploying to an environment that is not pg or prod." } - if ($login) { - Login -subscription $subscription -clusterGroup $clusterGroup -pushImages:$pushImages + if (!$skipLogin) { + Login -subscription $subscription -clusterGroup $clusterGroup -skipPushImages:$skipPushImages } $chartRepoName = 'stress-test-charts' @@ -162,8 +162,8 @@ function DeployStressTests( -deployId $deployer ` -environment $environment ` -repositoryBase $repository ` - -pushImages:$pushImages ` - -login:$login ` + -skipPushImages:$skipPushImages ` + -skipLogin:$skipLogin ` -clusterGroup $clusterGroup ` -subscription $subscription } @@ -189,8 +189,8 @@ function DeployStressPackage( [string]$deployId, [string]$environment, [string]$repositoryBase, - [switch]$pushImages, - [switch]$login, + [switch]$skipPushImages, + [switch]$skipLogin, [string]$clusterGroup, [string]$subscription ) { @@ -267,7 +267,7 @@ function DeployStressPackage( } $dockerfileName = ($dockerFilePath -split { $_ -in '\', '/' })[-1].ToLower() $imageTag = $imageTagBase + "/${dockerfileName}:${deployId}" - if ($pushImages) { + if (!$skipPushImages) { Write-Host "Building and pushing stress test docker image '$imageTag'" $dockerFile = Get-ChildItem $dockerFilePath @@ -290,8 +290,8 @@ function DeployStressPackage( Run docker push $imageTag if ($LASTEXITCODE) { - if ($login) { - Write-Warning "If docker push is failing due to authentication issues, try calling this script with '-Login'" + if (!$skipLogin) { + Write-Warning "If docker push is failing due to authentication issues, try calling this script without '-SkipLogin'" } } }