Ansible.Basic - Support a delegate type for option elements key (#52951)

This commit is contained in:
Jordan Borean 2019-02-26 08:14:10 +10:00 committed by GitHub
parent fe7cbc2554
commit 13f8f1481f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 56 additions and 3 deletions

View file

@ -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")