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))
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), )
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), )
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)
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
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)
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), )
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)
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, )
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)
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))
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))
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())
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)
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"}))
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")
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))
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)