Skip to content

Commit

Permalink
Fixed environment variable path
Browse files Browse the repository at this point in the history
Ticket: CFE-4468
Signed-off-by: Victor Moene <[email protected]>
  • Loading branch information
victormlg committed Dec 10, 2024
1 parent b7854f8 commit 7287b1c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cf_remote/paths.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from cf_remote.utils import user_error


def path_append(dir, subdir):
Expand All @@ -7,8 +8,17 @@ def path_append(dir, subdir):


def cfengine_dir(subdir=None):
cf_remote_dir = ".cfengine" if "CF_REMOTE_DIR" not in os.environ else os.environ["CF_REMOTE_DIR"]
return path_append("~/{}/".format(cf_remote_dir), subdir)
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)


def cf_remote_dir(subdir=None):
Expand Down

0 comments on commit 7287b1c

Please sign in to comment.