start on path helper methods

This commit is contained in:
Alan Rominger
2021-04-21 17:19:37 -04:00
parent 334be9eb25
commit 1f1cdf8859

View File

@@ -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)