windows: fix list type in legacy module utils (#30483)

* windows: fix list type in legacy module utils

* only change the return for the list type instead of affecting it all

* additional null check when using an array
This commit is contained in:
Jordan Borean 2017-09-19 14:18:52 +10:00 committed by Matt Davis
parent b7b57a811a
commit 01563ccd5d
3 changed files with 35 additions and 1 deletions

View file

@ -201,7 +201,9 @@ Function Get-AnsibleParam($obj, $name, $default = $null, $resultobj = @{}, $fail
# If $value -eq $null, the parameter was unspecified by the user (deliberately or not)
# Please leave $null-values intact, modules need to know if a parameter was specified
if ($value -ne $null) {
# When $value is already an array, we cannot rely on the null check, as an empty list
# is seen as null in the check below
if ($value -ne $null -or $value -is [array]) {
if ($type -eq "path") {
# Expand environment variables on path-type
$value = Expand-Environment($value)
@ -240,6 +242,8 @@ Function Get-AnsibleParam($obj, $name, $default = $null, $resultobj = @{}, $fail
} else {
Fail-Json -obj $resultobj -message "Get-AnsibleParam: Parameter '$name' is not a YAML list."
}
# , is not a typo, forces it to return as a list when it is empty or only has 1 entry
return ,$value
}
}