From 020105f5ae512e6622c8ee41d303a94388ea4bde Mon Sep 17 00:00:00 2001 From: Alexander Kasper Date: Thu, 12 Oct 2023 20:54:22 +0200 Subject: [PATCH 1/3] chg: only remove basicAuthUser from datasource if it is present If there is no check for its presence, this will fail if a datasource is not configured with basic auth at all. In that case it would try to remove an entry from the dict that is not there resulting in a KeyError. --- plugins/modules/grafana_datasource.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/modules/grafana_datasource.py b/plugins/modules/grafana_datasource.py index b0496a97..95faca2f 100644 --- a/plugins/modules/grafana_datasource.py +++ b/plugins/modules/grafana_datasource.py @@ -519,7 +519,8 @@ def compare_datasources(new, current, compareSecureData=True): if 'readOnly' in current: del current['readOnly'] if current['basicAuth'] is False: - del current['basicAuthUser'] + if 'basicAuthUser' in current: + del current['basicAuthUser'] if 'password' in current: del current['password'] if 'basicAuthPassword' in current: From 9e049562defa26396b0267a10b6963dfac82ba3b Mon Sep 17 00:00:00 2001 From: Alexander Kasper Date: Thu, 26 Oct 2023 07:57:10 +0200 Subject: [PATCH 2/3] add changelog fragment --- changelogs/fragments/fix-316.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/fix-316.yml diff --git a/changelogs/fragments/fix-316.yml b/changelogs/fragments/fix-316.yml new file mode 100644 index 00000000..4569d445 --- /dev/null +++ b/changelogs/fragments/fix-316.yml @@ -0,0 +1,2 @@ +bugfixes: + - Fix error with datasources configured without basicAuth \ No newline at end of file From b910e811381c420bf4215cbe7bb4673805c2cbcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20REY?= Date: Sun, 5 Nov 2023 00:46:17 +0100 Subject: [PATCH 3/3] Update plugins/modules/grafana_datasource.py fix indent --- plugins/modules/grafana_datasource.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/grafana_datasource.py b/plugins/modules/grafana_datasource.py index 95faca2f..5f865ec5 100644 --- a/plugins/modules/grafana_datasource.py +++ b/plugins/modules/grafana_datasource.py @@ -520,7 +520,7 @@ def compare_datasources(new, current, compareSecureData=True): del current['readOnly'] if current['basicAuth'] is False: if 'basicAuthUser' in current: - del current['basicAuthUser'] + del current['basicAuthUser'] if 'password' in current: del current['password'] if 'basicAuthPassword' in current: