mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-31 11:54:47 +00:00
idoveridegroup: Use module.params_get_type
Use the commom parameter type handling method for parameters that accept a value or an empty string.
This commit is contained in:
@@ -476,7 +476,7 @@ def main():
|
|||||||
params = {}
|
params = {}
|
||||||
for x in field_map:
|
for x in field_map:
|
||||||
val = ansible_module.params_get(
|
val = ansible_module.params_get(
|
||||||
x, allow_empty_list_item=(x in allow_empty_list_item))
|
x, allow_empty_list_item=x in allow_empty_list_item)
|
||||||
|
|
||||||
if val is not None:
|
if val is not None:
|
||||||
params[field_map.get(x, x)] = val
|
params[field_map.get(x, x)] = val
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ def main():
|
|||||||
# present
|
# present
|
||||||
description = ansible_module.params_get("description")
|
description = ansible_module.params_get("description")
|
||||||
name = ansible_module.params_get("name")
|
name = ansible_module.params_get("name")
|
||||||
gid = ansible_module.params_get("gid")
|
gid = ansible_module.params_get_with_type_cast("gid", int)
|
||||||
|
|
||||||
# runtime flags
|
# runtime flags
|
||||||
fallback_to_ldap = ansible_module.params_get("fallback_to_ldap")
|
fallback_to_ldap = ansible_module.params_get("fallback_to_ldap")
|
||||||
@@ -271,19 +271,6 @@ def main():
|
|||||||
|
|
||||||
ansible_module.params_fail_used_invalid(invalid, state)
|
ansible_module.params_fail_used_invalid(invalid, state)
|
||||||
|
|
||||||
# Ensure parameter values are valid and have proper type.
|
|
||||||
def int_or_empty_param(value, param):
|
|
||||||
if value is not None and value != "":
|
|
||||||
try:
|
|
||||||
value = int(value)
|
|
||||||
except ValueError:
|
|
||||||
ansible_module.fail_json(
|
|
||||||
msg="Invalid value '%s' for argument '%s'" % (value, param)
|
|
||||||
)
|
|
||||||
return value
|
|
||||||
|
|
||||||
gid = int_or_empty_param(gid, "gid")
|
|
||||||
|
|
||||||
# Init
|
# Init
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
|
|||||||
Reference in New Issue
Block a user