From 1f1cdf885938c1f26504ec7a7afea11f0e4eb1a9 Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Wed, 21 Apr 2021 17:19:37 -0400 Subject: [PATCH] start on path helper methods --- awx/main/utils/execution_environments.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/awx/main/utils/execution_environments.py b/awx/main/utils/execution_environments.py index ed6bb87f34..8e5ef7918a 100644 --- a/awx/main/utils/execution_environments.py +++ b/awx/main/utils/execution_environments.py @@ -1,3 +1,6 @@ +import os +from pathlib import Path + from django.conf import settings from awx.main.models.execution_environments import ExecutionEnvironment @@ -25,3 +28,16 @@ def get_default_pod_spec(): ], }, } + + +# this is the root of the private data dir as seen from inside +# of the container running a job +CONTAINER_ROOT = '/runner' + + +def to_container_path(path, private_data_dir): + if not os.path.isabs(private_data_dir): + raise Exception + if Path(private_data_dir) not in Path(path).parents: + raise Exception + return path.replace(private_data_dir, CONTAINER_ROOT)