예제 #1
0
def ui_edit_environment(name):
    conda_store = get_conda_store()
    environment = api.get_environment(conda_store.db, name)
    specification = api.get_specification(conda_store.db,
                                          environment.specification.sha256)
    return render_template("create.html",
                           specification=yaml.dump(specification.spec))
예제 #2
0
def ui_get_environment(name):
    conda_store = get_conda_store()
    return render_template(
        "environment.html",
        environment=api.get_environment(conda_store.db, name),
        environment_builds=api.get_environment_builds(conda_store.db, name),
    )
예제 #3
0
def ui_list_environments():
    conda_store = get_conda_store()
    return render_template(
        "home.html",
        environments=api.list_environments(conda_store.db),
        metrics=api.get_metrics(conda_store.db),
    )
예제 #4
0
def api_list_specification():
    conda_store = get_conda_store()
    orm_specifications = api.list_specifications(conda_store.db)
    specifications = [
        schema.Specification.from_orm(_).dict(exclude={"builds"})
        for _ in orm_specifications
    ]
    return jsonify(specifications)
예제 #5
0
def api_post_specification():
    conda_store = get_conda_store()
    try:
        specification = schema.CondaSpecification.parse_obj(request.json)
        api.post_specification(conda_store, specification)
        return jsonify({"status": "ok"})
    except pydantic.ValidationError as e:
        return jsonify({"status": "error", "error": e.errors()}), 400
예제 #6
0
def api_list_builds():
    conda_store = get_conda_store()
    orm_builds = api.list_builds(conda_store.db)
    builds = [
        schema.Build.from_orm(build).dict(exclude={"packages"})
        for build in orm_builds
    ]
    return jsonify(builds)
예제 #7
0
def ui_get_specification(sha256):
    conda_store = get_conda_store()
    specification = api.get_specification(conda_store.db, sha256)
    return render_template(
        "specification.html",
        specification=specification,
        spec=yaml.dump(specification.spec),
    )
예제 #8
0
def api_list_environments():
    conda_store = get_conda_store()
    orm_environments = api.list_environments(conda_store.db)
    environments = [
        schema.Environment.from_orm(_).dict(
            exclude={"specification": {"builds"}}) for _ in orm_environments
    ]
    return jsonify(environments)
예제 #9
0
def api_list_packages(provider):
    conda_store = get_conda_store()
    if provider == "conda":
        orm_packages = api.list_conda_packages(conda_store.db)
        packages = [
            schema.CondaPackage.from_orm(package).dict()
            for package in orm_packages
        ]
        return jsonify(packages)
    else:
        return (
            jsonify({
                "status": "error",
                "error": f'package provider "{provider}" not supported',
            }),
            400,
        )
예제 #10
0
def list_tags(rest):
    parts = rest.split("/")
    conda_store = get_conda_store()

    # /v2/<image>/tags/list
    if len(parts) > 2 and parts[-2:] == ["tags", "list"]:
        image = "/".join(parts[:-2])
        raise NotImplementedError()
    # /v2/<image>/manifests/<tag>
    elif len(parts) > 2 and parts[-2] == "manifests":
        image = "/".join(parts[:-2])
        tag = parts[-1]
        return get_docker_image_manifest(conda_store, image, tag)
    # /v2/<image>/blobs/<blobsum>
    elif len(parts) > 2 and parts[-2] == "blobs":
        image = "/".join(parts[:-2])
        blobsum = parts[-1].split(":")[1]
        return get_docker_image_blob(conda_store, image, blobsum)
    else:
        return docker_error_message(schema.DockerRegistryError.UNSUPPORTED)
예제 #11
0
def ui_create_get_environment():
    if request.method == "GET":
        return render_template("create.html")
    elif request.method == "POST":
        try:
            specification_text = request.form.get("specification")
            conda_store = get_conda_store()
            specification = schema.CondaSpecification.parse_obj(
                yaml.safe_load(specification_text))
            api.post_specification(conda_store, specification.dict())
            return redirect("/")
        except yaml.YAMLError:
            return render_template(
                "create.html",
                specification=specification_text,
                message="Unable to parse. Invalid YAML",
            )
        except pydantic.ValidationError as e:
            return render_template("create.html",
                                   specification=specification_text,
                                   message=str(e))
예제 #12
0
def api_get_build_logs(build_id):
    conda_store = get_conda_store()
    log_key = api.get_build(conda_store.db, build_id).log_key
    return redirect(conda_store.storage.get_url(log_key))
예제 #13
0
def api_get_build(build_id):
    conda_store = get_conda_store()
    build = schema.Build.from_orm(api.get_build(conda_store.db, build_id))
    return jsonify(build.dict())
예제 #14
0
def ui_get_build(build_id):
    conda_store = get_conda_store()
    build = api.get_build(conda_store.db, build_id)
    return render_template("build.html", build=build)
예제 #15
0
def api_get_specification(sha256):
    conda_store = get_conda_store()
    specification = schema.Specification.from_orm(
        api.get_specification(conda_store.db, sha256))
    return jsonify(specification.dict(exclude={"builds"}))
예제 #16
0
def api_get_build_lockfile(build_id):
    conda_store = get_conda_store()
    lockfile = api.get_build_lockfile(conda_store.db, build_id)
    return Response(lockfile, mimetype="text/plain")
예제 #17
0
def api_get_build_archive(build_id):
    conda_store = get_conda_store()
    conda_pack_key = api.get_build(conda_store.db, build_id).conda_pack_key
    return redirect(conda_store.storage.get_url(conda_pack_key))
예제 #18
0
def api_get_environment(name):
    conda_store = get_conda_store()
    environment = schema.Environment.from_orm(
        api.get_environment(conda_store.db, name)).dict()
    return jsonify(environment)