summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJordan Borean <jborean93@gmail.com>2017-09-19 14:18:52 +1000
committerMatt Davis <nitzmahone@users.noreply.github.com>2017-09-18 21:18:52 -0700
commit01563ccd5dfc9936397b7480f3f50531fb54edbd (patch)
tree75c425a177b0f71c9b5763adb22b4dbd583db040 /lib
parentb7b57a811ac4937a88b63b40542919557d34374c (diff)
downloadansible-01563ccd5dfc9936397b7480f3f50531fb54edbd.tar.gz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm16
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1 b/lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1
index a526211be0..76f5f1454f 100644
--- a/lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1
+++ b/lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1
@@ -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
}
}