Exemplo n.º 1
0
def assembly_metadata_config(releases_config: Model,
                             assembly: typing.Optional[str], meta_type: str,
                             distgit_key: str, meta_config: Model) -> Model:
    """
    Returns a group member's metadata configuration based on the assembly information
    and the initial file-based config.
    :param releases_config: A Model for releases.yaml.
    :param assembly: The name of the assembly
    :param meta_type: 'rpm' or 'image'
    :param distgit_key: The member's distgit_key
    :param meta_config: The meta's config object
    :return: Returns a computed config for the metadata (e.g. value for meta.config).
    """
    if not assembly or not isinstance(releases_config, Model):
        return meta_config

    _check_recursion(releases_config, assembly)
    target_assembly = releases_config.releases[assembly].assembly

    if target_assembly.basis.assembly:  # Does this assembly inherit from another?
        # Recursive apply ancestor assemblies
        meta_config = assembly_metadata_config(releases_config,
                                               target_assembly.basis.assembly,
                                               meta_type, distgit_key,
                                               meta_config)

    config_dict = meta_config.primitive()

    component_list = target_assembly.members[f'{meta_type}s']
    for component_entry in component_list:
        if component_entry.distgit_key == '*' or component_entry.distgit_key == distgit_key and component_entry.metadata:
            config_dict = merger(component_entry.metadata.primitive(),
                                 config_dict)

    return Model(dict_to_model=config_dict)
Exemplo n.º 2
0
def assembly_streams_config(releases_config: Model,
                            assembly: typing.Optional[str],
                            streams_config: Model) -> Model:
    """
    Returns a streams config based on the assembly information
    and the input group config.
    :param releases_config: A Model for releases.yaml.
    :param assembly: The name of the assembly
    :param streams_config: The streams config to merge into a new streams config (original Model will not be altered)
    """
    if not assembly or not isinstance(releases_config, Model):
        return streams_config

    _check_recursion(releases_config, assembly)
    target_assembly = releases_config.releases[assembly].assembly

    if target_assembly.basis.assembly:  # Does this assembly inherit from another?
        # Recursively apply ancestor assemblies
        streams_config = assembly_streams_config(
            releases_config, target_assembly.basis.assembly, streams_config)

    target_assembly_streams = target_assembly.group
    if not target_assembly_streams:
        return streams_config

    return Model(dict_to_model=merger(target_assembly_streams.primitive(),
                                      streams_config.primitive()))