1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Improve parameter checking

required_one_of=[] is neat.

Co-authored-by: Alexei Znamensky
This commit is contained in:
George Rawlinson 2021-05-21 16:22:15 +12:00
parent f848326ecd
commit 044b0cbc85
No known key found for this signature in database
GPG key ID: E0959FEA8B550539

View file

@ -140,15 +140,6 @@ class PacmanKey(object):
fingerprint = self.sanitise_fingerprint(fingerprint) fingerprint = self.sanitise_fingerprint(fingerprint)
key_present = self.key_in_keyring(keyid, keyring) key_present = self.key_in_keyring(keyid, keyring)
if (
state == "present"
and data is None
and file is None
and url is None
and keyserver is None
):
module.fail_json(msg="expected one of: data, file, url, keyserver. got none")
if module.check_mode: if module.check_mode:
if state == "present": if state == "present":
if (key_present and force_update) or not key_present: if (key_present and force_update) or not key_present:
@ -331,6 +322,7 @@ def main():
), ),
supports_check_mode=True, supports_check_mode=True,
mutually_exclusive=(('data', 'file', 'url', 'keyserver'),), mutually_exclusive=(('data', 'file', 'url', 'keyserver'),),
required_one_of=[('data', 'file', 'url', 'keyserver'),],
) )
PacmanKey(module) PacmanKey(module)