Support github user namespaces for codespaces environments (#3316)

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
This commit is contained in:
Azure SDK Bot 2022-02-04 12:04:23 -08:00 committed by GitHub
parent 514080fa0c
commit 4e67da9775
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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]@{