Skip to content

Commit 7a4b67a

Browse files
azure-sdkbenbp
andauthored
Support github user namespaces for codespaces environments (Azure#20218)
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
1 parent fc85dc2 commit 7a4b67a

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

eng/common/scripts/stress-testing/find-all-stress-packages.ps1

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,18 @@ function NewStressTestPackageInfo([hashtable]$chart, [System.IO.FileInfo]$chartF
4545
$namespace = if ($CI) {
4646
$chart.annotations.namespace
4747
} else {
48-
$namespace = if ($env:USER) { $env:USER } else { "${env:USERNAME}" }
49-
# Remove spaces, etc. that may be in $namespace
50-
$namespace -replace '\W'
48+
# Check GITHUB_USER for users in codespaces environments, since the default user is `codespaces` and
49+
# we would like to avoid namespace overlaps for different codespaces users.
50+
$namespace = if ($env:GITHUB_USER) {
51+
$env:GITHUB_USER
52+
} elseif ($env:USER) {
53+
$env:USER
54+
} else {
55+
$env:USERNAME
56+
}
57+
# Remove spaces, underscores, etc. that may be in $namespace. Value must be a valid RFC 1123 DNS label:
58+
# https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names
59+
$namespace -replace '_|\W', '-'
5160
}
5261

5362
return [StressTestPackageInfo]@{

0 commit comments

Comments
 (0)