From a8d0171e36fecf9cce8a53bd0962d6a4a3a46f19 Mon Sep 17 00:00:00 2001 From: Rafael Guterres Jeffman Date: Mon, 18 Sep 2023 12:44:45 -0300 Subject: [PATCH] idoveridegroup: Use module.params_get_type Use the commom parameter type handling method for parameters that accept a value or an empty string. --- plugins/modules/ipaconfig.py | 2 +- plugins/modules/ipaidoverridegroup.py | 15 +-------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/plugins/modules/ipaconfig.py b/plugins/modules/ipaconfig.py index b94b3c7262..da57e7cc38 100644 --- a/plugins/modules/ipaconfig.py +++ b/plugins/modules/ipaconfig.py @@ -476,7 +476,7 @@ def main(): params = {} for x in field_map: 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: params[field_map.get(x, x)] = val diff --git a/plugins/modules/ipaidoverridegroup.py b/plugins/modules/ipaidoverridegroup.py index 5767251654..975c90733d 100644 --- a/plugins/modules/ipaidoverridegroup.py +++ b/plugins/modules/ipaidoverridegroup.py @@ -243,7 +243,7 @@ def main(): # present description = ansible_module.params_get("description") name = ansible_module.params_get("name") - gid = ansible_module.params_get("gid") + gid = ansible_module.params_get_type("gid", int) # runtime flags fallback_to_ldap = ansible_module.params_get("fallback_to_ldap") @@ -271,19 +271,6 @@ def main(): 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 changed = False