From 044b0cbc854744480ad1e17753e33f0371c7d0eb Mon Sep 17 00:00:00 2001 From: George Rawlinson Date: Fri, 21 May 2021 16:22:15 +1200 Subject: [PATCH] Improve parameter checking required_one_of=[] is neat. Co-authored-by: Alexei Znamensky --- plugins/modules/packaging/os/pacman_key.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/plugins/modules/packaging/os/pacman_key.py b/plugins/modules/packaging/os/pacman_key.py index 921126b2ad..04d1514a30 100644 --- a/plugins/modules/packaging/os/pacman_key.py +++ b/plugins/modules/packaging/os/pacman_key.py @@ -140,15 +140,6 @@ class PacmanKey(object): fingerprint = self.sanitise_fingerprint(fingerprint) 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 state == "present": if (key_present and force_update) or not key_present: @@ -331,6 +322,7 @@ def main(): ), supports_check_mode=True, mutually_exclusive=(('data', 'file', 'url', 'keyserver'),), + required_one_of=[('data', 'file', 'url', 'keyserver'),], ) PacmanKey(module)