parent
3bccfb1615
commit
940b7af7d8
4 changed files with 46 additions and 2 deletions
2
changelogs/fragments/74029-argspec-apply_defaults.yml
Normal file
2
changelogs/fragments/74029-argspec-apply_defaults.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- "argument spec validation - fix behavior of ``apply_defaults=True`` when an empty dictionary is specified for such an option (https://github.com/ansible/ansible/pull/74029)."
|
|
@ -702,8 +702,8 @@ def _validate_sub_spec(argument_spec, parameters, prefix='', options_context=Non
|
|||
if sub_spec is not None:
|
||||
if parameters.get(param) is None:
|
||||
parameters[param] = {}
|
||||
else:
|
||||
continue
|
||||
else:
|
||||
continue
|
||||
elif sub_spec is None or param not in parameters or parameters[param] is None:
|
||||
continue
|
||||
|
||||
|
|
|
@ -126,6 +126,19 @@ def main():
|
|||
'int': {
|
||||
'type': 'int',
|
||||
},
|
||||
'apply_defaults': {
|
||||
'type': 'dict',
|
||||
'apply_defaults': True,
|
||||
'options': {
|
||||
'foo': {
|
||||
'type': 'str',
|
||||
},
|
||||
'bar': {
|
||||
'type': 'str',
|
||||
'default': 'baz',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
required_if=(
|
||||
('state', 'present', ('path', 'content'), True),
|
||||
|
|
|
@ -342,6 +342,30 @@
|
|||
register: argspec_int_invalid
|
||||
ignore_errors: true
|
||||
|
||||
- argspec:
|
||||
required: value
|
||||
required_one_of_one: value
|
||||
register: argspec_apply_defaults_not_specified
|
||||
|
||||
- argspec:
|
||||
required: value
|
||||
required_one_of_one: value
|
||||
apply_defaults: ~
|
||||
register: argspec_apply_defaults_none
|
||||
|
||||
- argspec:
|
||||
required: value
|
||||
required_one_of_one: value
|
||||
apply_defaults: {}
|
||||
register: argspec_apply_defaults_empty
|
||||
|
||||
- argspec:
|
||||
required: value
|
||||
required_one_of_one: value
|
||||
apply_defaults:
|
||||
foo: bar
|
||||
register: argspec_apply_defaults_one
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- argspec_required_fail is failed
|
||||
|
@ -417,3 +441,8 @@
|
|||
- argspec_password_no_log.stdout|regex_findall('VALUE_SPECIFIED_IN_NO_LOG_PARAMETER')|length == 1
|
||||
|
||||
- argspec_int_invalid is failed
|
||||
|
||||
- "argspec_apply_defaults_not_specified.apply_defaults == {'foo': none, 'bar': 'baz'}"
|
||||
- "argspec_apply_defaults_none.apply_defaults == {'foo': none, 'bar': 'baz'}"
|
||||
- "argspec_apply_defaults_empty.apply_defaults == {'foo': none, 'bar': 'baz'}"
|
||||
- "argspec_apply_defaults_one.apply_defaults == {'foo': 'bar', 'bar': 'baz'}"
|
||||
|
|
Loading…
Reference in a new issue