Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(grafana_datasource): remove field apiVersion from return of current datasource #396

Merged
merged 3 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/396-datasource-diff-apiversion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- Remove field `apiVersion` from return of current `grafana_datasource` for working diff
43 changes: 24 additions & 19 deletions plugins/modules/grafana_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,25 +537,30 @@


def compare_datasources(new, current, compareSecureData=True):
if new["uid"] is None:
del current["uid"]
del new["uid"]
del current["typeLogoUrl"]
del current["id"]
if "version" in current:
del current["version"]
if "readOnly" in current:
del current["readOnly"]
if current["basicAuth"] is False:
if "basicAuthUser" in current:
del current["basicAuthUser"]
if "password" in current:
del current["password"]
if "basicAuthPassword" in current:
del current["basicAuthPassword"]
if current["type"] == "grafana-postgresql-datasource" and new["type"] == "postgres":
del current["type"]
del new["type"]
if new.get("uid") is None:
new.pop("uid", None)
current.pop("uid", None)

for field in [
"apiVersion",
"basicAuthPassword",
"id",
"password",
"readOnly",
"typeLogoUrl",
"version",
]:
current.pop(field, None)

if not current.get("basicAuth", True):
current.pop("basicAuthUser", None)

if (
current.get("type") == "grafana-postgresql-datasource"
and new.get("type") == "postgres"
):
new.pop("type", None)
current.pop("type", None)

# check if secureJsonData should be compared
if not compareSecureData:
Expand Down
Loading