Fix up deprecated_aliases spot for PS (#66326)

This commit is contained in:
Jordan Borean 2020-01-10 11:44:15 +10:00 committed by GitHub
parent 3c0a836004
commit 7ed00a1560
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 37 deletions

View file

@ -685,26 +685,26 @@ namespace Ansible.Basic
if (parameters.Contains(alias))
parameters[k] = parameters[alias];
}
}
List<Hashtable> deprecatedAliases = (List<Hashtable>)argumentSpec["deprecated_aliases"];
foreach (Hashtable depInfo in deprecatedAliases)
{
foreach (string keyName in new List<string> { "name", "version" })
List<Hashtable> deprecatedAliases = (List<Hashtable>)v["deprecated_aliases"];
foreach (Hashtable depInfo in deprecatedAliases)
{
if (!depInfo.ContainsKey(keyName))
foreach (string keyName in new List<string> { "name", "version" })
{
string msg = String.Format("{0} is required in a deprecated_aliases entry", keyName);
throw new ArgumentException(FormatOptionsContext(msg, " - "));
if (!depInfo.ContainsKey(keyName))
{
string msg = String.Format("{0} is required in a deprecated_aliases entry", keyName);
throw new ArgumentException(FormatOptionsContext(msg, " - "));
}
}
}
string aliasName = (string)depInfo["name"];
string depVersion = (string)depInfo["version"];
string aliasName = (string)depInfo["name"];
string depVersion = (string)depInfo["version"];
if (parameters.Contains(aliasName))
{
string msg = String.Format("Alias '{0}' is deprecated. See the module docs for more information", aliasName);
Deprecate(FormatOptionsContext(msg, " - "), depVersion);
if (parameters.Contains(aliasName))
{
string msg = String.Format("Alias '{0}' is deprecated. See the module docs for more information", aliasName);
Deprecate(FormatOptionsContext(msg, " - "), depVersion);
}
}
}
@ -1334,4 +1334,3 @@ namespace Ansible.Basic
}
}
}

View file

@ -796,24 +796,16 @@ test_no_log - Invoked with:
"Deprecated aliases" = {
$spec = @{
options = @{
option1 = @{ type = "str"; aliases = "alias1" }
option2 = @{ type = "str"; aliases = "alias2" }
option1 = @{ type = "str"; aliases = "alias1"; deprecated_aliases = @(@{name = "alias1"; version = "2.10"}) }
option2 = @{ type = "str"; aliases = "alias2"; deprecated_aliases = @(@{name = "alias2"; version = "2.11"}) }
option3 = @{
type = "dict"
options = @{
option1 = @{ type = "str"; aliases = "alias1" }
option2 = @{ type = "str"; aliases = "alias2" }
option1 = @{ type = "str"; aliases = "alias1"; deprecated_aliases = @(@{name = "alias1"; version = "2.10"}) }
option2 = @{ type = "str"; aliases = "alias2"; deprecated_aliases = @(@{name = "alias2"; version = "2.11"}) }
}
deprecated_aliases = @(
@{ name = "alias1"; version = "2.10" }
@{ name = "alias2"; version = "2.11" }
)
}
}
deprecated_aliases = @(
@{ name = "alias1"; version = "2.10" }
@{ name = "alias2"; version = "2.11" }
)
}
$complex_args = @{
@ -1666,12 +1658,11 @@ test_no_log - Invoked with:
option_key = @{
type = "str"
aliases = ,"alias_name"
deprecated_aliases = @(
@{name = "alias_name"}
)
}
}
deprecated_aliases = @(
@{name = "alias_name"}
)
}
$failed = $false
@ -1701,13 +1692,11 @@ test_no_log - Invoked with:
sub_option_key = @{
type = "str"
aliases = ,"alias_name"
deprecated_aliases = @(
@{version = "2.10"}
)
}
}
deprecated_aliases = @(
@{version = "2.10"}
)
}
}
}
@ -2578,3 +2567,4 @@ try {
}
Exit-Module