-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: export dashboard with pretty printed JSON
Resolves: #257
- Loading branch information
Showing
4 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- Export dashboard with pretty printed JSON so that it becomes easier to compare changes with the previous version (#257) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
tests/integration/targets/grafana_dashboard/tasks/dashboard-export.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
- set_fact: | ||
dashboard_uid: "{{ result.uid }}" | ||
|
||
- name: Check export grafana dashboard to file | ||
grafana_dashboard: | ||
grafana_url: "{{ grafana_url }}" | ||
grafana_user: "{{ grafana_username }}" | ||
grafana_password: "{{ grafana_password }}" | ||
state: export | ||
path: /tmp/dashboard.json | ||
overwrite: true | ||
uid: "{{ dashboard_uid }}" | ||
register: result | ||
|
||
- debug: | ||
var: result | ||
|
||
- assert: | ||
that: | ||
- "result.changed == true" | ||
- "result.msg == 'Dashboard {{ dashboard_uid }} exported to /tmp/dashboard.json'" | ||
|
||
- name: Load /tmp/dashboard.json or fail if missing | ||
set_fact: | ||
exported_dashboard_lines: "{{ lookup('file', '/tmp/dashboard.json').splitlines() }}" | ||
|
||
- name: Assert that exported dashboard contains formatted JSON | ||
assert: | ||
that: | ||
- "exported_dashboard_lines | length >= 2" | ||
- "exported_dashboard_lines[0] == '{'" | ||
- "exported_dashboard_lines[-1] == '}'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters