Skip to content
Snippets Groups Projects
Commit bc694b72 authored by Rafael Guterres Jeffman's avatar Rafael Guterres Jeffman
Browse files

idoverideuser: Use module.params_get_type

Use the commom parameter type handling method for parameters that accept
a value or an empty string.
parent 92d579be
No related branches found
No related tags found
No related merge requests found
...@@ -439,9 +439,9 @@ def main(): ...@@ -439,9 +439,9 @@ 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")
uid = ansible_module.params_get("uid") uid = ansible_module.params_get_with_type_cast("uid", int)
gecos = ansible_module.params_get("gecos") gecos = ansible_module.params_get("gecos")
gidnumber = ansible_module.params_get("gidnumber") gidnumber = ansible_module.params_get_with_type_cast("gidnumber", int)
homedir = ansible_module.params_get("homedir") homedir = ansible_module.params_get("homedir")
shell = ansible_module.params_get("shell") shell = ansible_module.params_get("shell")
sshpubkey = ansible_module.params_get("sshpubkey") sshpubkey = ansible_module.params_get("sshpubkey")
...@@ -479,20 +479,6 @@ def main(): ...@@ -479,20 +479,6 @@ def main():
ansible_module.params_fail_used_invalid(invalid, state, action) ansible_module.params_fail_used_invalid(invalid, state, action)
# 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
uid = int_or_empty_param(uid, "uid")
gidnumber = int_or_empty_param(gidnumber, "gidnumber")
if certificate is not None: if certificate is not None:
certificate = [cert.strip() for cert in certificate] certificate = [cert.strip() for cert in certificate]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment