From b5fb0c8247aba96112a75954f1b4db1754379f30 Mon Sep 17 00:00:00 2001 From: Tony Fernandez Date: Wed, 23 Oct 2024 17:33:09 -0400 Subject: [PATCH] added returns when expected values are not provided --- borgmatic/hooks/zabbix.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/borgmatic/hooks/zabbix.py b/borgmatic/hooks/zabbix.py index 101b5711..ffcd05ee 100644 --- a/borgmatic/hooks/zabbix.py +++ b/borgmatic/hooks/zabbix.py @@ -53,9 +53,11 @@ def ping_monitor(hook_config, config, config_filename, state, monitoring_log_lev elif host is not None: logger.warning( f'{config_filename}: Key missing for Zabbix authentication' ) + return elif key is not None: logger.warning( f'{config_filename}: Host missing for Zabbix authentication' ) + return # Determine the authentication method: API key or username/password auth = None @@ -69,10 +71,12 @@ def ping_monitor(hook_config, config, config_filename, state, monitoring_log_lev data['auth'] = response.json().get('result') elif username is not None: - logger.warning( f'{config_filename}: Password missing for Zabbix authentication, defaulting to no auth' ) + logger.warning( f'{config_filename}: Password missing for Zabbix authentication' ) + return elif password is not None: - logger.warning( f'{config_filename}: Username missing for Zabbix authentication, defaulting to no auth' ) + logger.warning( f'{config_filename}: Username missing for Zabbix authentication' ) + return if not dry_run: logging.getLogger('urllib3').setLevel(logging.ERROR)