Work in progress: Docker -> ACI conversion

This commit is contained in:
Joseph Schorr 2015-01-13 17:46:11 -05:00
parent df9a417207
commit 6ed28930b2
13 changed files with 424 additions and 162 deletions

View file

@ -8,8 +8,9 @@ class TarLayerReadException(Exception):
class TarLayerFormat(object):
""" Class which creates a generator of the combined TAR data. """
def __init__(self, tar_iterator):
def __init__(self, tar_iterator, path_prefix=None):
self.tar_iterator = tar_iterator
self.path_prefix = path_prefix
def get_generator(self):
for current_tar in self.tar_iterator():
@ -36,7 +37,12 @@ class TarLayerFormat(object):
continue
# Yield the tar header.
yield tar_info.tobuf()
if self.path_prefix:
clone = tarfile.TarInfo.frombuf(tar_info.tobuf())
clone.name = os.path.join(self.path_prefix, clone.name)
yield clone.tobuf()
else:
yield tar_info.tobuf()
# Try to extract any file contents for the tar. If found, we yield them as well.
if tar_info.isreg():