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 authored and rndmh3ro committed Jan 18, 2024
1 parent 879e206 commit a390e97
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 = (
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)
if ds is None:
grafana_iface.create_datasource(payload)
ds = grafana_iface.datasource_by_name(name)
Expand Down

0 comments on commit a390e97

Please sign in to comment.