ansible-collections / community.grafana

Grafana Collection for Ansible
http://galaxy.ansible.com/community/grafana
GNU General Public License v3.0
129 stars 82 forks source link

Fix KeyError when comparing datasource without basicAuth #316

Closed LiMuBei closed 11 months ago

LiMuBei commented 12 months ago

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.

SUMMARY

When comparing the existing datasource with the should be state, basicAuth is handled incorrectly in the case when the datasource is not configured with basicAuth at all. This case would result in a KeyError which this change fixes.

ISSUE TYPE
COMPONENT NAME

grafana_datasource.py

See also https://github.com/ansible-collections/community.grafana/issues/248

seuf commented 11 months ago

HEllo @LiMuBei . Regarding the checls failure, you need to add a changelog fragment so the tests can pass

codecov[bot] commented 11 months ago

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (7ab900f) 71.07% compared to head (b910e81) 71.03%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #316 +/- ## ========================================== - Coverage 71.07% 71.03% -0.04% ========================================== Files 18 18 Lines 1853 1854 +1 Branches 318 319 +1 ========================================== Hits 1317 1317 Misses 396 396 - Partials 140 141 +1 ``` | [Flag](https://app.codecov.io/gh/ansible-collections/community.grafana/pull/316/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ansible-collections) | Coverage Δ | | |---|---|---| | [integration](https://app.codecov.io/gh/ansible-collections/community.grafana/pull/316/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ansible-collections) | `69.74% <50.00%> (-0.07%)` | :arrow_down: | | [sanity](https://app.codecov.io/gh/ansible-collections/community.grafana/pull/316/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ansible-collections) | `23.78% <0.00%> (-0.02%)` | :arrow_down: | | [units](https://app.codecov.io/gh/ansible-collections/community.grafana/pull/316/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ansible-collections) | `65.59% <0.00%> (-0.07%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ansible-collections#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/ansible-collections/community.grafana/pull/316?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ansible-collections) | Coverage Δ | | |---|---|---| | [plugins/modules/grafana\_datasource.py](https://app.codecov.io/gh/ansible-collections/community.grafana/pull/316?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ansible-collections#diff-cGx1Z2lucy9tb2R1bGVzL2dyYWZhbmFfZGF0YXNvdXJjZS5weQ==) | `76.71% <50.00%> (-0.41%)` | :arrow_down: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

LiMuBei commented 11 months ago

HEllo @LiMuBei . Regarding the checls failure, you need to add a changelog fragment so the tests can pass

Hi. I added a fragment.