Skip to content

Commit 3732370

Browse files
authored
Merge pull request #243 from acjohnson/242fix
add missing argument http_get_headers (resolves #242)
2 parents 48e96d7 + 0e5c642 commit 3732370

File tree

7 files changed

+29
-12
lines changed

7 files changed

+29
-12
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
# [1.4.1] - 2023-09-21
8+
9+
### Added
10+
11+
### Changed
12+
- add missing argument http_get_headers #242 #243
13+
14+
### Removed
15+
716
# [1.4.0] - 2023-09-20
817

918
### Added

grafana_backup/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
homedir = os.environ["HOME"]
88

99
PKG_NAME = "grafana-backup"
10-
PKG_VERSION = "1.4.0"
10+
PKG_VERSION = "1.4.1"
1111
JSON_CONFIG_PATH = "{0}/.grafana-backup.json".format(homedir)

grafana_backup/create_contact_point.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
def main(args, settings, file_path):
77
grafana_url = settings.get('GRAFANA_URL')
88
http_post_headers = settings.get('HTTP_POST_HEADERS')
9+
http_get_headers = settings.get('HTTP_GET_HEADERS')
910
verify_ssl = settings.get('VERIFY_SSL')
1011
client_cert = settings.get('CLIENT_CERT')
1112
debug = settings.get('DEBUG')
1213

1314
try:
14-
grafana_version = get_grafana_version(grafana_url, verify_ssl)
15+
grafana_version = get_grafana_version(grafana_url, verify_ssl, http_get_headers)
1516
except KeyError as error:
1617
if not grafana_version:
1718
raise Exception("Grafana version is not set.") from error

grafana_backup/save_alert_rules.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ def main(args, settings):
1717
log_file = 'alert_rules_{0}.txt'.format(timestamp)
1818
grafana_version_string = settings.get('GRAFANA_VERSION')
1919
if grafana_version_string:
20-
grafana_version = version.parse(grafana_version_string)
20+
grafana_version = version.parse(grafana_version_string)
2121

2222
try:
23-
grafana_version = get_grafana_version(grafana_url, verify_ssl, http_get_headers)
23+
grafana_version = get_grafana_version(
24+
grafana_url, verify_ssl, http_get_headers)
2425
except KeyError as error:
2526
if not grafana_version:
2627
raise Exception("Grafana version is not set.") from error
@@ -32,9 +33,11 @@ def main(args, settings):
3233
if not os.path.exists(folder_path):
3334
os.makedirs(folder_path)
3435

35-
save_alert_rules(folder_path, log_file, grafana_url, http_get_headers, verify_ssl, client_cert, debug, pretty_print)
36+
save_alert_rules(folder_path, log_file, grafana_url,
37+
http_get_headers, verify_ssl, client_cert, debug, pretty_print)
3638
else:
37-
print("Unable to save alert rules, requires Grafana version {0} or above. Current version is {1}".format(minimum_version, grafana_version))
39+
print("Unable to save alert rules, requires Grafana version {0} or above. Current version is {1}".format(
40+
minimum_version, grafana_version))
3841

3942

4043
def get_all_alert_rules_in_grafana(grafana_url, http_get_headers, verify_ssl, client_cert, debug):
@@ -46,14 +49,17 @@ def get_all_alert_rules_in_grafana(grafana_url, http_get_headers, verify_ssl, cl
4649
alert_rules = content
4750
print("There are {0} alert rules:".format(len(alert_rules)))
4851
for alert_rule in alert_rules:
49-
print('name: {0}'.format(to_python2_and_3_compatible_string(alert_rule['title'])))
52+
print('name: {0}'.format(
53+
to_python2_and_3_compatible_string(alert_rule['title'])))
5054
return alert_rules
5155
else:
52-
raise Exception("Failed to get alert rules, status: {0}, msg: {1}".format(status, content))
56+
raise Exception(
57+
"Failed to get alert rules, status: {0}, msg: {1}".format(status, content))
5358

5459

5560
def save_alert_rules(folder_path, log_file, grafana_url, http_get_headers, verify_ssl, client_cert, debug, pretty_print):
56-
alert_rules = get_all_alert_rules_in_grafana(grafana_url, http_get_headers, verify_ssl, client_cert, debug)
61+
alert_rules = get_all_alert_rules_in_grafana(
62+
grafana_url, http_get_headers, verify_ssl, client_cert, debug)
5763
for alert_rule in alert_rules:
5864
print_horizontal_line()
5965
print(alert_rule)

grafana_backup/save_contact_points.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def main(args, settings):
2121
grafana_version = version.parse(grafana_version_string)
2222

2323
try:
24-
grafana_version = get_grafana_version(grafana_url, verify_ssl)
24+
grafana_version = get_grafana_version(grafana_url, verify_ssl, http_get_headers)
2525
except KeyError as error:
2626
if not grafana_version:
2727
raise Exception("Grafana version is not set.") from error

grafana_backup/save_notification_policies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def main(args, settings):
2121
grafana_version = version.parse(grafana_version_string)
2222

2323
try:
24-
grafana_version = get_grafana_version(grafana_url, verify_ssl)
24+
grafana_version = get_grafana_version(grafana_url, verify_ssl, http_get_headers)
2525
except KeyError as error:
2626
if not grafana_version:
2727
raise Exception("Grafana version is not set.") from error

grafana_backup/update_notification_policy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
def main(args, settings, file_path):
77
grafana_url = settings.get('GRAFANA_URL')
88
http_post_headers = settings.get('HTTP_POST_HEADERS')
9+
http_get_headers = settings.get('HTTP_GET_HEADERS')
910
verify_ssl = settings.get('VERIFY_SSL')
1011
client_cert = settings.get('CLIENT_CERT')
1112
debug = settings.get('DEBUG')
1213

1314
try:
14-
grafana_version = get_grafana_version(grafana_url, verify_ssl)
15+
grafana_version = get_grafana_version(grafana_url, verify_ssl, http_get_headers)
1516
except KeyError as error:
1617
if not grafana_version:
1718
raise Exception("Grafana version is not set.") from error

0 commit comments

Comments
 (0)