From 4e67da97755881ee5e335030207d65d5f1f24c3e Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Fri, 4 Feb 2022 12:04:23 -0800 Subject: [PATCH] Support github user namespaces for codespaces environments (#3316) Co-authored-by: Ben Broderick Phillips --- .../stress-testing/find-all-stress-packages.ps1 | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/eng/common/scripts/stress-testing/find-all-stress-packages.ps1 b/eng/common/scripts/stress-testing/find-all-stress-packages.ps1 index 73731e410..bda7da1a6 100644 --- a/eng/common/scripts/stress-testing/find-all-stress-packages.ps1 +++ b/eng/common/scripts/stress-testing/find-all-stress-packages.ps1 @@ -45,9 +45,18 @@ function NewStressTestPackageInfo([hashtable]$chart, [System.IO.FileInfo]$chartF $namespace = if ($CI) { $chart.annotations.namespace } else { - $namespace = if ($env:USER) { $env:USER } else { "${env:USERNAME}" } - # Remove spaces, etc. that may be in $namespace - $namespace -replace '\W' + # Check GITHUB_USER for users in codespaces environments, since the default user is `codespaces` and + # we would like to avoid namespace overlaps for different codespaces users. + $namespace = if ($env:GITHUB_USER) { + $env:GITHUB_USER + } elseif ($env:USER) { + $env:USER + } else { + $env:USERNAME + } + # Remove spaces, underscores, etc. that may be in $namespace. Value must be a valid RFC 1123 DNS label: + # https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names + $namespace -replace '_|\W', '-' } return [StressTestPackageInfo]@{