From f6f84b5df74ff3560dbaff8093cb4f2f1e581a4d Mon Sep 17 00:00:00 2001 From: Victor Moene Date: Tue, 10 Dec 2024 11:21:21 +0100 Subject: [PATCH] Added environment variable for cf-remote path Ticket: CFE-4468 Signed-off-by: Victor Moene --- cf_remote/paths.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cf_remote/paths.py b/cf_remote/paths.py index 07b7e73..e80cd2b 100644 --- a/cf_remote/paths.py +++ b/cf_remote/paths.py @@ -1,4 +1,5 @@ import os +from cf_remote.utils import user_error def path_append(dir, subdir): @@ -7,6 +8,16 @@ def path_append(dir, subdir): def cfengine_dir(subdir=None): + override_dir = os.getenv("CF_REMOTE_DIR") + + if override_dir: + parent = os.path.dirname(override_dir) + + if not os.path.exists(parent): + user_error("'{}' doesn't exist. Make sure this path is correct and exists.".format(parent)) + + return path_append(override_dir, subdir) + return path_append("~/.cfengine/", subdir)