Skip to content

Commit

Permalink
fix: orgId by name if defined to compare diff
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemental committed Jan 17, 2024
1 parent 879e206 commit 41596d3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions plugins/modules/grafana_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,9 @@ def compare_datasources(new, current, compareSecureData=True):
return dict(before=current, after=new)


def get_datasource_payload(data):
def get_datasource_payload(data, org_id):
payload = {
"orgId": data["org_id"],
"orgId": org_id,
"name": data["name"],
"uid": data["uid"],
"type": data["ds_type"],
Expand Down Expand Up @@ -921,9 +921,14 @@ def main():

grafana_iface = GrafanaInterface(module)
ds = grafana_iface.datasource_by_name(name)
org_id = (

Check warning on line 924 in plugins/modules/grafana_datasource.py

View check run for this annotation

Codecov / codecov/patch

plugins/modules/grafana_datasource.py#L924

Added line #L924 was not covered by tests
grafana_iface.organization_by_name(module.params["org_name"])
if module.params["org_name"]
else module.params["org_id"]
)

if state == "present":
payload = get_datasource_payload(module.params)
payload = get_datasource_payload(module.params, org_id)

Check warning on line 931 in plugins/modules/grafana_datasource.py

View check run for this annotation

Codecov / codecov/patch

plugins/modules/grafana_datasource.py#L931

Added line #L931 was not covered by tests
if ds is None:
grafana_iface.create_datasource(payload)
ds = grafana_iface.datasource_by_name(name)
Expand Down

0 comments on commit 41596d3

Please sign in to comment.