Skip to content

Commit

Permalink
re-formatting with black
Browse files Browse the repository at this point in the history
  • Loading branch information
johndoe12312 authored and rndmh3ro committed Jan 30, 2024
1 parent 2842d16 commit f9c2e88
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion changelogs/fragments/311_dashboard_check_mode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ minor_changes:
- grafana_dashboard - add check_mode support

trivial:
- Refactor tests for `grafana_dashboard`
- Refactor tests for `grafana_dashboard`
38 changes: 23 additions & 15 deletions plugins/modules/grafana_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,12 @@ def grafana_create_dashboard(module, data):

if grafana_dashboard_changed:
if module.check_mode:
module.exit_json(uid=uid,
failed=False,
changed=True,
msg="Dashboard %s will be updated" % payload['dashboard']['title'])
module.exit_json(
uid=uid,
failed=False,
changed=True,
msg="Dashboard %s will be updated" % payload["dashboard"]["title"],
)
# update
if "overwrite" in data and data["overwrite"]:
payload["overwrite"] = True
Expand Down Expand Up @@ -454,9 +456,11 @@ def grafana_create_dashboard(module, data):
result["changed"] = False
else:
if module.check_mode:
module.exit_json(failed=False,
changed=True,
msg="Dashboard %s will be created" % payload['dashboard']['title'])
module.exit_json(
failed=False,
changed=True,
msg="Dashboard %s will be created" % payload["dashboard"]["title"],
)

# Ensure there is no id in payload
if "id" in payload["dashboard"]:
Expand Down Expand Up @@ -512,10 +516,12 @@ def grafana_delete_dashboard(module, data):
result = {}
if dashboard_exists is True:
if module.check_mode:
module.exit_json(uid=uid,
failed=False,
changed=True,
msg="Dashboard %s will be deleted" % uid)
module.exit_json(
uid=uid,
failed=False,
changed=True,
msg="Dashboard %s will be deleted" % uid,
)

# delete
if grafana_version < 5:
Expand Down Expand Up @@ -574,10 +580,12 @@ def grafana_export_dashboard(module, data):

if dashboard_exists is True:
if module.check_mode:
module.exit_json(uid=uid,
failed=False,
changed=True,
msg="Dashboard %s will be exported to %s" % (uid, data['path']))
module.exit_json(
uid=uid,
failed=False,
changed=True,
msg="Dashboard %s will be exported to %s" % (uid, data["path"]),
)
try:
with open(data["path"], "w", encoding="utf-8") as f:
f.write(json.dumps(dashboard, indent=2))
Expand Down

0 comments on commit f9c2e88

Please sign in to comment.