Skip to content
This repository was archived by the owner on Jan 19, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion atomicapp/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def run(self):
if hasattr(args, item) and getattr(args, item) is not None:
args.cli_answers[item] = getattr(args, item)

lock = LockFile(os.path.join(Utils.getRoot(), LOCK_FILE))
lock = LockFile(Utils.get_real_abspath(LOCK_FILE))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to rebase this on my PR on removing the lockfile, but that's fine :)

try:
if args.action != 'init':
lock.acquire(timeout=-1)
Expand Down
9 changes: 3 additions & 6 deletions atomicapp/nulecule/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,11 @@ def __init__(self, app_spec, destination=None,

# Adjust app_spec, destination, and answer file paths if absolute.
if os.path.isabs(app_spec):
app_spec = os.path.join(Utils.getRoot(),
app_spec.lstrip('/'))
app_spec = Utils.get_real_abspath(app_spec)
if destination and os.path.isabs(destination):
destination = os.path.join(Utils.getRoot(),
destination.lstrip('/'))
destination = Utils.get_real_abspath(destination)
if answers_file and os.path.isabs(answers_file):
answers_file = os.path.join(Utils.getRoot(),
answers_file.lstrip('/'))
answers_file = Utils.get_real_abspath(answers_file)

# If the user doesn't want the files copied to a permanent
# location then he provides 'none'. If that is the case we'll
Expand Down
3 changes: 1 addition & 2 deletions atomicapp/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ def getConfigFile(self):
if PROVIDER_CONFIG_KEY in self.config:
self.config_file = self.config[PROVIDER_CONFIG_KEY]
if os.path.isabs(self.config_file):
self.config_file = os.path.join(Utils.getRoot(),
self.config_file.lstrip('/'))
self.config_file = Utils.get_real_abspath(self.config_file)
else:
logger.warning("Configuration option '%s' not found" % PROVIDER_CONFIG_KEY)

Expand Down
2 changes: 1 addition & 1 deletion atomicapp/providers/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def init(self):
if self.container:
self.kubectl = self._find_kubectl(Utils.getRoot())
kube_conf_path = "/etc/kubernetes"
host_kube_conf_path = os.path.join(Utils.getRoot(), kube_conf_path.lstrip("/"))
host_kube_conf_path = Utils.get_real_abspath(kube_conf_path)
if not os.path.exists(kube_conf_path) and os.path.exists(host_kube_conf_path):
if self.dryrun:
logger.info("DRY-RUN: link %s from %s" % (kube_conf_path, host_kube_conf_path))
Expand Down
3 changes: 1 addition & 2 deletions atomicapp/providers/openshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,7 @@ def _set_config_values(self):
self.provider_tls_verify = result[PROVIDER_TLS_VERIFY_KEY]
if result[PROVIDER_CA_KEY]:
# if we are in container translate path to path on host
self.provider_ca = os.path.join(Utils.getRoot(),
result[PROVIDER_CA_KEY].lstrip('/'))
self.provider_ca = Utils.get_real_abspath(result[PROVIDER_CA_KEY])
else:
self.provider_ca = None

Expand Down
15 changes: 15 additions & 0 deletions atomicapp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,21 @@ def getRoot():
else:
return "/"

@staticmethod
def get_real_abspath(path):
"""
Take the user provided 'path' and return the real path to the resource
irrespective of the app running location either inside container or
outside.

Args:
path (str): path to a resource

Returns:
str: absolute path to resource in the filesystem.
"""
return os.path.join(Utils.getRoot(), path.lstrip('/'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment about what this function is doing if you don't mind.


# generates a unique 12 character UUID
@staticmethod
def getUniqueUUID():
Expand Down