From 49e2647f4730bab2d5b98e94d099c55907981d35 Mon Sep 17 00:00:00 2001 From: Victoria Martinez de la Cruz Date: Thu, 3 Apr 2025 09:58:04 +0000 Subject: [PATCH] Check if the HOME env var is set, otherwise use a default This patch adds code to check if the env var HOME is set, otherwise uses a default value Change-Id: I8b1de9f41ba77c8026321bc9e67a951db32745f4 --- observabilityclient/utils/metric_utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/observabilityclient/utils/metric_utils.py b/observabilityclient/utils/metric_utils.py index 6b1826b..b3eb5e9 100644 --- a/observabilityclient/utils/metric_utils.py +++ b/observabilityclient/utils/metric_utils.py @@ -20,8 +20,11 @@ import yaml from observabilityclient.prometheus_client import PrometheusAPIClient -DEFAULT_CONFIG_LOCATIONS = [os.environ["HOME"] + "/.config/openstack/", - "/etc/openstack/"] +DEFAULT_CONFIG_LOCATIONS = ( + [os.path.join(os.environ["HOME"], ".config/openstack/"), "/etc/openstack/"] + if "HOME" in os.environ + else ["/etc/openstack/"] +) CONFIG_FILE_NAME = "prometheus.yaml" LOG = logging.getLogger(__name__)