コード例 #1
0
ファイル: util.py プロジェクト: adarshtri/doozer
def what_is_in_master() -> str:
    """
    :return: Returns a string like "4.6" to identify which release currently resides in master branch.
    """
    # The promotion target of the openshift/images master branch defines this release master is associated with.
    ci_config_url = 'https://raw.githubusercontent.com/openshift/release/master/ci-operator/config/openshift/images/openshift-images-master.yaml'
    content = exectools.urlopen_assert(ci_config_url).read()
    ci_config = yaml.safe_load(content)
    # Look for something like: https://github.com/openshift/release/blob/251cb12e913dcde7be7a2b36a211650ed91c45c4/ci-operator/config/openshift/images/openshift-images-master.yaml#L64
    target_release = ci_config.get('promotion', {}).get('name', None)
    if not target_release:
        red_print(content)
        raise IOError('Unable to find which openshift release resides in master')
    return target_release
コード例 #2
0
def get_channel_versions(
        channel,
        arch,
        graph_url='https://api.openshift.com/api/upgrades_info/v1/graph',
        graph_content_stable=None,
        graph_content_candidate=None):
    """
    Queries Cincinnati and returns a tuple containing:
    1. All of the versions in the specified channel in decending order (e.g. 4.6.26, ... ,4.6.1)
    2. A map of the edges associated with each version (e.g. map['4.6.1'] -> [ '4.6.2', '4.6.3', ... ]
    :param channel: The name of the channel to inspect
    :param arch: Arch for the channel
    :param graph_url: Cincinnati graph URL to query
    :param graph_content_candidate: Override content from candidate channel - primarily for testing
    :param graph_content_stable: Override content from stable channel - primarily for testing
    :return: (versions, edge_map)
    """
    content = None
    if (channel == 'stable') and graph_content_stable:
        # permit override
        with open(graph_content_stable, 'r') as f:
            content = f.read()

    if (channel != 'stable') and graph_content_candidate:
        # permit override
        with open(graph_content_candidate, 'r') as f:
            content = f.read()

    if not content:
        url = f'{graph_url}?arch={arch}&channel={channel}'
        req = urllib.request.Request(url)
        req.add_header('Accept', 'application/json')
        content = exectools.urlopen_assert(req).read()

    graph = json.loads(content)
    versions = [node['version'] for node in graph['nodes']]
    descending_versions = sort_semver(versions)

    edges: Dict[str, List] = dict()
    for v in versions:
        # Ensure there is at least an empty list for all versions.
        edges[v] = []

    for edge_def in graph['edges']:
        # edge_def example [22, 20] where is number is an offset into versions
        from_ver = versions[edge_def[0]]
        to_ver = versions[edge_def[1]]
        edges[from_ver].append(to_ver)

    return descending_versions, edges
コード例 #3
0
ファイル: util.py プロジェクト: vfreex/doozer
def get_build_suggestions(major, minor, arch,
                          suggestions_url='https://raw.githubusercontent.com/openshift/cincinnati-graph-data/master/build-suggestions/'):
    """
    Loads suggestions_url/major.minor.yaml and returns minor_min, minor_max,
    minor_block_list, z_min, z_max, and z_block_list
    :param suggestions_url: Base url to /{major}.{minor}.yaml
    :param major: Major version
    :param minor: Minor version
    :param arch: Architecture to lookup
    :return: {minor_min, minor_max, minor_block_list, z_min, z_max, z_block_list}
    """
    url = f'{suggestions_url}/{major}.{minor}.yaml'
    req = urllib.request.Request(url)
    req.add_header('Accept', 'application/yaml')
    suggestions = yaml.safe_load(exectools.urlopen_assert(req))
    if arch in suggestions:
        return suggestions[arch]
    else:
        return suggestions['default']