Fix missing config variable rewrite

This commit is contained in:
Orsiris de Jong 2023-01-26 01:52:03 +01:00
parent cf0a1dc909
commit e63d6558a8

View file

@ -29,28 +29,28 @@ from version import NAME, VERSION
logger = getLogger(__intname__) logger = getLogger(__intname__)
def metric_writer(config: dict, restic_result: bool, result_string: str): def metric_writer(config_dict: dict, restic_result: bool, result_string: str):
try: try:
if config["prometheus"]["metrics"]: if config_dict["prometheus"]["metrics"]:
# Evaluate variables # Evaluate variables
if config["prometheus"]["instance"] == "${HOSTNAME}": if config_dict["prometheus"]["instance"] == "${HOSTNAME}":
instance = platform.node() instance = platform.node()
else: else:
instance = config["prometheus"]["instance"] instance = config_dict["prometheus"]["instance"]
if config["prometheus"]["backup_job"] == "${HOSTNAME}": if config_dict["prometheus"]["backup_job"] == "${HOSTNAME}":
backup_job = platform.node() backup_job = platform.node()
else: else:
backup_job = config["prometheus"]["backup_job"] backup_job = config_dict["prometheus"]["backup_job"]
try: try:
prometheus_group = config["prometheus"]["group"] prometheus_group = config_dict["prometheus"]["group"]
except (KeyError, AttributeError): except (KeyError, AttributeError):
prometheus_group = None prometheus_group = None
try: try:
prometheus_additional_labels = config["prometheus"]["additional_labels"] prometheus_additional_labels = config_dict["prometheus"]["additional_labels"]
except (KeyError, AttributeError): except (KeyError, AttributeError):
prometheus_additional_labels = None prometheus_additional_labels = None
destination = config["prometheus"]["destination"] destination = config_dict["prometheus"]["destination"]
destination = destination.replace("${BACKUP_JOB}", backup_job) destination = destination.replace("${BACKUP_JOB}", backup_job)
# Configure lables # Configure lables
@ -85,8 +85,8 @@ def metric_writer(config: dict, restic_result: bool, result_string: str):
if destination.lower().startswith("http"): if destination.lower().startswith("http"):
try: try:
authentication = ( authentication = (
config["prometheus"]["http_username"], config_dict["prometheus"]["http_username"],
config["prometheus"]["http_password"], config_dict["prometheus"]["http_password"],
) )
except KeyError: except KeyError:
logger.info("No metrics authentication present.") logger.info("No metrics authentication present.")
@ -354,7 +354,7 @@ class NPBackupRunner:
exclude_caches = False exclude_caches = False
try: try:
one_file_system = ( one_file_system = (
config["backup"]["one_file_system"] if os.name != "nt" else False self.config_dict["backup"]["one_file_system"] if os.name != "nt" else False
) )
except KeyError: except KeyError:
one_file_system = False one_file_system = False