Beispiel #1
0
def _assembly_config_struct(releases_config: Model,
                            assembly: typing.Optional[str], key: str, default):
    """
    If a key is directly under the 'assembly' (e.g. rhcos), then this method will
    recurse the inheritance tree to build you a final version of that key's value.
    The key may refer to a list or dict (set default value appropriately).
    """
    if not assembly or not isinstance(releases_config, Model):
        return Missing

    _check_recursion(releases_config, assembly)
    target_assembly = releases_config.releases[assembly].assembly
    key_struct = target_assembly.get(key, default)
    if target_assembly.basis.assembly:  # Does this assembly inherit from another?
        # Recursive apply ancestor assemblies
        parent_config_struct = _assembly_config_struct(
            releases_config, target_assembly.basis.assembly, key, default)
        key_struct = merger(key_struct, parent_config_struct.primitive())
    if isinstance(default, dict):
        return Model(dict_to_model=key_struct)
    elif isinstance(default, list):
        return ListModel(list_to_model=key_struct)
    else:
        raise ValueError(
            f'Unknown how to derive for default type: {type(default)}')
Beispiel #2
0
def assembly_permits(releases_config: Model,
                     assembly: typing.Optional[str]) -> ListModel:
    """
    :param releases_config: The content of releases.yml in Model form.
    :param assembly: The name of the assembly to assess
    Returns the a computed permits config model for a given assembly. If no
    permits are defined ListModel([]) is returned.
    """

    defined_permits = _assembly_config_struct(releases_config, assembly,
                                              'permits', [])

    if not defined_permits and (
            assembly == 'stream' or not assembly
    ):  # If assembly is None, this a group without assemblies enabled
        # TODO: Address this formally with https://issues.redhat.com/browse/ART-3162 .
        # In the short term, we need to allow certain inconsistencies for stream.
        # We don't want common pre-GA issues to stop all nightlies.
        default_stream_permits = [{
            'code': 'OUTDATED_RPMS_IN_STREAM_BUILD',
            'component': '*'
        }, {
            'code': 'CONFLICTING_GROUP_RPM_INSTALLED',
            'component': 'rhcos'
        }]
        return ListModel(list_to_model=default_stream_permits)

    # Do some basic validation here to fail fast
    if assembly_type(releases_config, assembly) == AssemblyTypes.STANDARD:
        if defined_permits:
            raise ValueError(
                f'STANDARD assemblies like {assembly} do not allow "permits"')

    for permit in defined_permits:
        if permit.code == AssemblyIssueCode.IMPERMISSIBLE.name:
            raise ValueError(
                f'IMPERMISSIBLE cannot be permitted in any assembly (assembly: {assembly})'
            )
        if permit.code not in ['*', *[aic.name for aic in AssemblyIssueCode]]:
            raise ValueError(
                f'Undefined permit code in assembly {assembly}: {permit.code}')
    return defined_permits
Beispiel #3
0
def get_container_configs(runtime):
    """
    look up the group.yml configuration for RHCOS container(s) for this group, or create if missing.
    @return ListModel with Model entries like ^^ default_primary_container
    """
    return runtime.group_config.rhcos.payload_tags or ListModel([default_primary_container])