Skip to content

Commit

Permalink
Improve type and null handling
Browse files Browse the repository at this point in the history
  • Loading branch information
benbp committed Feb 14, 2024
1 parent 52e3eda commit c46c2cf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions eng/common/scripts/job-matrix/job-matrix-functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ function ProcessReplace {
$replaceMatrix = @()

foreach ($element in $matrix) {
if (!$element || [bool]$element.PSobject.Properties.name -notmatch "_permutation") {
if (!$element || $element.PSobject.Properties.name -notcontains "_permutation") {
continue
}
$replacement = [MatrixParameter[]]@()
Expand Down Expand Up @@ -374,15 +374,15 @@ function ProcessEnvironmentVariableReferences([array]$matrix, $displayNamesLooku
$updatedMatrix = @()

foreach ($element in $matrix) {
if (!$element || [bool]$element.PSobject.Properties.name -notmatch "_permutation") {
if (!$element || $element.PSobject.Properties.name -notcontains "_permutation") {
continue
}
$updated = [MatrixParameter[]]@()

foreach ($perm in $element._permutation) {
# Iterate nested permutations or run once for singular values (int, string, bool)
foreach ($flattened in $perm.Flatten()) {
if ($flattened.Value?.GetType() -eq "".GetType() -and $flattened.Value.StartsWith("env:")) {
if ($flattened.Value -is [string] -and $flattened.Value.StartsWith("env:")) {
$envKey = $flattened.Value.Replace("env:", "")
$value = [System.Environment]::GetEnvironmentVariable($envKey) ?? ""
if (!$value) {
Expand Down

0 comments on commit c46c2cf

Please sign in to comment.