From 77c42e7e1839ce8a54259a63636f41fbb8cabad8 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 5 Apr 2022 07:49:27 +0200 Subject: [PATCH] Bug fix: Warns user if incorrect SDK version is installed (#4422) (#4449) * Add error handling to check correct SDK version installed * Fix CI errors * Added changelog fragment * Changed exeption type * Update changelogs fragment Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein (cherry picked from commit e7ffa76db6dd3e27a9891c06c0356a9899856548) Co-authored-by: Ricky White --- ...2-warn-user-if-incorrect-SDK-version-is-installed.yaml | 3 +++ plugins/lookup/dsv.py | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/4422-warn-user-if-incorrect-SDK-version-is-installed.yaml diff --git a/changelogs/fragments/4422-warn-user-if-incorrect-SDK-version-is-installed.yaml b/changelogs/fragments/4422-warn-user-if-incorrect-SDK-version-is-installed.yaml new file mode 100644 index 0000000000..af03dae757 --- /dev/null +++ b/changelogs/fragments/4422-warn-user-if-incorrect-SDK-version-is-installed.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - dsv lookup plugin - raise an Ansible error if the wrong ``python-dsv-sdk`` version is installed (https://github.com/ansible-collections/community.general/pull/4422). \ No newline at end of file diff --git a/plugins/lookup/dsv.py b/plugins/lookup/dsv.py index d7826bcd4d..1cd9041a2e 100644 --- a/plugins/lookup/dsv.py +++ b/plugins/lookup/dsv.py @@ -105,11 +105,15 @@ display = Display() class LookupModule(LookupBase): @staticmethod def Client(vault_parameters): - return SecretsVault(**vault_parameters) + try: + vault = SecretsVault(**vault_parameters) + return vault + except TypeError: + raise AnsibleError("python-dsv-sdk==0.0.1 must be installed to use this plugin") def run(self, terms, variables, **kwargs): if sdk_is_missing: - raise AnsibleError("python-dsv-sdk must be installed to use this plugin") + raise AnsibleError("python-dsv-sdk==0.0.1 must be installed to use this plugin") self.set_options(var_options=variables, direct=kwargs)