mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
Ansible.Basic - Support a delegate type for option elements key (#52951)
This commit is contained in:
parent
fe7cbc2554
commit
13f8f1481f
2 changed files with 56 additions and 3 deletions
|
@ -1039,13 +1039,26 @@ namespace Ansible.Basic
|
|||
|
||||
private void CheckSubOption(IDictionary param, string key, IDictionary spec)
|
||||
{
|
||||
object value = param[key];
|
||||
|
||||
string type;
|
||||
if (spec["type"].GetType() == typeof(string))
|
||||
type = (string)spec["type"];
|
||||
else
|
||||
type = "delegate";
|
||||
string elements = (string)spec["elements"];
|
||||
object value = param[key];
|
||||
|
||||
string elements = null;
|
||||
Delegate typeConverter = null;
|
||||
if (spec["elements"] != null && spec["elements"].GetType() == typeof(string))
|
||||
{
|
||||
elements = (string)spec["elements"];
|
||||
typeConverter = optionTypes[elements];
|
||||
}
|
||||
else if (spec["elements"] != null)
|
||||
{
|
||||
elements = "delegate";
|
||||
typeConverter = (Delegate)spec["elements"];
|
||||
}
|
||||
|
||||
if (!(type == "dict" || (type == "list" && elements != null)))
|
||||
// either not a dict, or list with the elements set, so continue
|
||||
|
@ -1057,7 +1070,6 @@ namespace Ansible.Basic
|
|||
return;
|
||||
|
||||
List<object> newValue = new List<object>();
|
||||
Delegate typeConverter = optionTypes[elements];
|
||||
foreach (object element in (List<object>)value)
|
||||
{
|
||||
if (elements == "dict")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue