Swap defaults: -Login and -PushImages to -SkipLogin and -SkipPushImages (#4626)
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
This commit is contained in:
parent
68d051fe72
commit
5a348b6766
@ -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
|
||||
|
||||
@ -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'"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user