Ejemplo n.º 1
0
    def build(self):
        """Information related to the build image."""

        # Map the final image to the correct build image
        run_image = self.container_config['base']['image']
        spack_version = self.container_config['base']['spack']
        image, tag = build_info(run_image, spack_version)

        Build = collections.namedtuple('Build', ['image', 'tag'])
        return Build(image=image, tag=tag)
Ejemplo n.º 2
0
def _stage_base_images(images_config):
    """Return a tuple with the base images to be used at the various stages.

    Args:
        images_config (dict): configuration under container:images
    """
    # If we have custom base images, just return them verbatim.
    build_stage = images_config.get('build', None)
    if build_stage:
        final_stage = images_config['final']
        return None, build_stage, final_stage

    # Check the operating system: this will be the base of the bootstrap
    # stage, if there, and of the final stage.
    operating_system = images_config.get('os', None)

    # Check the OS is mentioned in the internal data stored in a JSON file
    images_json = data()['images']
    if not any(os_name == operating_system for os_name in images_json):
        msg = ('invalid operating system name "{0}". '
               '[Allowed values are {1}]')
        msg = msg.format(operating_system, ', '.join(data()['images']))
        raise ValueError(msg)

    # Retrieve the build stage
    spack_info = images_config['spack']
    if isinstance(spack_info, dict):
        build_stage = 'bootstrap'
    else:
        spack_version = images_config['spack']
        image_name, tag = build_info(operating_system, spack_version)
        build_stage = 'bootstrap'
        if image_name:
            build_stage = ':'.join([image_name, tag])

    # Retrieve the bootstrap stage
    bootstrap_stage = None
    if build_stage == 'bootstrap':
        bootstrap_stage = images_json[operating_system]['bootstrap'].get(
            'image', operating_system
        )

    # Retrieve the final stage
    final_stage = images_json[operating_system].get(
        'final', {'image': operating_system}
    )['image']

    return bootstrap_stage, build_stage, final_stage
Ejemplo n.º 3
0
    def build(self):
        """Information related to the build image."""
        images_config = self.container_config['images']

        # Check if we have custom images
        image = images_config.get('build', None)

        # If not select the correct build image based on OS and Spack version
        if image is None:
            operating_system = images_config['os']
            spack_version = images_config['spack']
            image_name, tag = build_info(operating_system, spack_version)
            image = ':'.join([image_name, tag])

        Build = collections.namedtuple('Build', ['image'])
        return Build(image=image)