mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Ensure string types (#42362)
* actually enforce string types * unquote after its text * fixed incorrect template type * fixing string showed error in template typing
This commit is contained in:
parent
381263ad99
commit
4a7940c562
2 changed files with 5 additions and 2 deletions
|
@ -99,7 +99,10 @@ def ensure_type(value, value_type, origin=None):
|
||||||
value = value.split(',')
|
value = value.split(',')
|
||||||
value = [resolve_path(x, basedir=basedir) for x in value]
|
value = [resolve_path(x, basedir=basedir) for x in value]
|
||||||
|
|
||||||
# defaults to string types
|
elif value_type in ('str', 'string'):
|
||||||
|
value = unquote(to_text(value, errors='surrogate_or_strict'))
|
||||||
|
|
||||||
|
# defaults to string type
|
||||||
elif isinstance(value, string_types):
|
elif isinstance(value, string_types):
|
||||||
value = unquote(value)
|
value = unquote(value)
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ class ActionModule(ActionBase):
|
||||||
|
|
||||||
for b_type in ('force', 'follow', 'trim_blocks'):
|
for b_type in ('force', 'follow', 'trim_blocks'):
|
||||||
value = locals()[b_type]
|
value = locals()[b_type]
|
||||||
value = ensure_type(value, 'string')
|
value = ensure_type(value, 'boolean')
|
||||||
if value is not None and not isinstance(value, bool):
|
if value is not None and not isinstance(value, bool):
|
||||||
raise AnsibleActionFail("%s is expected to be a boolean, but got %s instead" % (b_type, type(value)))
|
raise AnsibleActionFail("%s is expected to be a boolean, but got %s instead" % (b_type, type(value)))
|
||||||
locals()[b_type] = value
|
locals()[b_type] = value
|
||||||
|
|
Loading…
Reference in a new issue