Skip to content

Commit

Permalink
powershell: Add support for list parameters (ansible#23131)
Browse files Browse the repository at this point in the history
This is a first implementation of list parameters.

It will convert a single string, or comma-separated value into an Array.
  • Loading branch information
dagwieers authored and KKoukiou committed May 22, 2017
1 parent 1950568 commit 29e5ea5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/ansible/module_utils/powershell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 29e5ea5

Please sign in to comment.