win_dsc - be more lenient with datetime parsing (#59703)

* win_dsc - be more lenient with datetime parsing

* Remove l that shouldn't be there
This commit is contained in:
Jordan Borean 2019-07-31 08:45:37 +10:00 committed by GitHub
parent 196347ff32
commit 04ec47bdf1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 7 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- win_dsc - Be more leniant around the accepted DateTime values for backwards compatibility - https://github.com/ansible/ansible/issues/59667

View file

@ -19,11 +19,7 @@ Function ConvertTo-ArgSpecType {
$arg_type = switch($CimType) {
Boolean { "bool" }
Char16 { [Func[[Object], [Char]]]{ [System.Char]::Parse($args[0].ToString()) } }
DateTime { [Func[[Object], [DateTime]]]{
# o == ISO 8601 format
[System.DateTime]::ParseExact($args[0].ToString(), "o", [CultureInfo]::InvariantCulture,
[System.Globalization.DateTimeStyles]::None)
}}
DateTime { [Func[[Object], [DateTime]]]{ [System.DateTime]($args[0].ToString()) } }
Instance { "dict" }
Real32 { "float" }
Real64 { [Func[[Object], [Double]]]{ [System.Double]::Parse($args[0].ToString()) } }

View file

@ -54,8 +54,9 @@ options:
provided but a comma separated string also work. Use a list where
possible as no escaping is required and it works with more complex types
list C(CimInstance[]).
- If the type of the DSC resource option is a C(DateTime), use a string in
the form of an ISO 8901 string.
- If the type of the DSC resource option is a C(DateTime), you should use
a string in the form of an ISO 8901 string to ensure the exact date is
used.
- Since Ansible 2.8, Ansible will now validate the input fields against the
DSC resource definition automatically. Older versions will silently
ignore invalid fields.