Skip to content

Commit

Permalink
factor out a bit more
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasheinrich committed Jun 29, 2017
1 parent 1d71d68 commit e8d7e9d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions packtivity/handlers/environment_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ def sourcepath(path):
else:
return path

def state_context_to_mounts(context):
readwrites = context.readwrite
readonlies = context.readonly
mounts = ''
for rw in readwrites:
mounts += '-v {}:{}:rw'.format(sourcepath(os.path.abspath(rw)),rw)
for ro in readonlies:
mounts += ' -v {}:{}:ro'.format(sourcepath(ro),ro)
return mounts

def cvmfs_from_volume_plugin(command_line,cvmfs_repos = None):
if not cvmfs_repos:
cvmfs_repos = yaml.load(os.environ.get('PACKTIVITY_CVMFS_REPOS','null'))
Expand All @@ -36,14 +46,10 @@ def cvmfs_from_external_mount(command_line):
def prepare_docker(context,do_cvmfs,do_auth,log):
nametag = context.identifier()
metadir = context.metadir
readwrites = context.readwrite
readonlies = context.readonly

docker_mod = ''
for rw in readwrites:
docker_mod += '-v {}:{}:rw'.format(sourcepath(os.path.abspath(rw)),rw)
for ro in readonlies:
docker_mod += ' -v {}:{}:ro'.format(sourcepath(ro),ro)

docker_mod = state_context_to_mounts(context)

if do_cvmfs:
cvmfs_source = os.environ.get('PACKTIVITY_CVMFS_SOURCE','external')
Expand All @@ -68,7 +74,6 @@ def prepare_docker(context,do_cvmfs,do_auth,log):

return docker_mod


def prepare_docker_context(context,environment,log):
container = environment['image']
report = '''\n\
Expand Down

0 comments on commit e8d7e9d

Please sign in to comment.