Ejemplo n.º 1
0
def list_dockerhub_tags():

    reponame = getattr(settings, 'DOCKER_REPO', None)
    if reponame is None:
        raise Exception('Unable to determine the current docker repo/image in use.')

    # we'll assume dockerhub for the time being
    dxf = DXF('registry-1.docker.io', reponame, auth)

    return dxf.list_aliases()
Ejemplo n.º 2
0
def find_current_tag(image, config):
    registry = DXF(image.fullhost(), image.fullrepo(), registry_auth)
    # FIXME: fail if check fails
    #print(registry.api_version_check())
    p = re.compile(config["tag"])
    candidates = []
    for tag in registry.list_aliases(iterate=True):
        if p.match(tag):
            candidates.append(tag)
    if len(candidates) == 0:
        return None

    # more than one? sort by semver, highest 1st
    if len(candidates) > 1:
        candidates = sorted(candidates,
                            reverse=True,
                            key=functools.cmp_to_key(semver.compare))

    return candidates[0]