Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def init(self):
"""
Initializes the image object.
"""
LOGGER.debug("Removing old target directory")
shutil.rmtree(self.target, ignore_errors=True)
os.makedirs(os.path.join(self.target, 'image'))
# Read the main image descriptor and create an Image object from it
descriptor = tools.load_descriptor(self._descriptor_path)
if isinstance(descriptor, list):
LOGGER.info("Descriptor contains multiple elements, assuming multi-stage image")
LOGGER.info("Found {} builder image(s) and one target image".format(
len(descriptor[:-1])))
# Iterate over images defined in image descriptor and
# create Image objects out of them
for image_descriptor in descriptor[:-1]:
self.builder_images.append(
Image(image_descriptor, os.path.dirname(os.path.abspath(self._descriptor_path))))
descriptor = descriptor[-1]
self.image = Image(descriptor, os.path.dirname(os.path.abspath(self._descriptor_path)))
def load_repository(self, repo_dir):
for modules_dir, _, files in os.walk(repo_dir):
if 'module.yaml' in files:
module_descriptor_path = os.path.abspath(os.path.expanduser(
os.path.normcase(os.path.join(modules_dir, 'module.yaml'))))
module = Module(tools.load_descriptor(module_descriptor_path),
modules_dir,
os.path.dirname(module_descriptor_path))
logger.debug("Adding module '%s', path: '%s'" % (module.name, module.path))
self._module_registry.add_module(module)