From 29e5ea5fe95528afbf746bf57c27e9a9f6547971 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Tue, 9 May 2017 02:53:13 +0200 Subject: [PATCH] powershell: Add support for list parameters (#23131) This is a first implementation of list parameters. It will convert a single string, or comma-separated value into an Array. --- lib/ansible/module_utils/powershell.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/ansible/module_utils/powershell.ps1 b/lib/ansible/module_utils/powershell.ps1 index 642d23cb42cd50..1198f7c962db9c 100644 --- a/lib/ansible/module_utils/powershell.ps1 +++ b/lib/ansible/module_utils/powershell.ps1 @@ -216,6 +216,15 @@ Function Get-AnsibleParam($obj, $name, $default = $null, $resultobj = @{}, $fail } elseif ($value -ne $null -and $type -eq "float") { # Convert float types to real Powershell floats $value = $value -as [float] + } elseif ($value -ne $null -and $type -eq "list") { + if ($value -is [array]) { + # Nothing to do + } elseif ($value -is [string]) { + # Convert string type to real Powershell array + $value = $value -split "," + } else { + Fail-Json -obj $resultobj -message "Parameter $name is not a Yaml list." + } } return $value