From d9a4a66592d56ce965da9b2968217892fbbd3c64 Mon Sep 17 00:00:00 2001 From: sophia Date: Mon, 25 Nov 2024 17:06:55 -0800 Subject: [PATCH] Deprecate api endpoint /build//docker rfc https://datatracker.ietf.org/doc/html/draft-ietf-httpapi-deprecation-header suggests using a "Deprecation" header in the response with the intended deprecation date. We don't have a specific date, so we'll set the value of this header to true. --- .../_internal/server/views/api.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/conda-store-server/conda_store_server/_internal/server/views/api.py b/conda-store-server/conda_store_server/_internal/server/views/api.py index 443dada5..1b55425c 100644 --- a/conda-store-server/conda_store_server/_internal/server/views/api.py +++ b/conda-store-server/conda_store_server/_internal/server/views/api.py @@ -9,7 +9,7 @@ import yaml from celery.result import AsyncResult from fastapi import APIRouter, Body, Depends, HTTPException, Query, Request -from fastapi.responses import PlainTextResponse, RedirectResponse +from fastapi.responses import PlainTextResponse, RedirectResponse, JSONResponse from conda_store_server import __version__, api, app from conda_store_server._internal import orm, schema, utils @@ -1348,7 +1348,7 @@ async def api_get_build_docker_image_url( server=Depends(dependencies.get_server), auth=Depends(dependencies.get_auth), ): - # TODO: remove this route + response_headers = {"Deprecation": "True"} with conda_store.get_db() as db: build = api.get_build(db, build_id) auth.authorize_request( @@ -1360,12 +1360,17 @@ async def api_get_build_docker_image_url( if build.has_docker_manifest: url = f"{server.registry_external_url}/{build.environment.namespace.name}/{build.environment.name}:{build.build_key}" - return PlainTextResponse(url) + return PlainTextResponse(url, headers=response_headers) else: - raise HTTPException( + content = { + "status": "error", + "message": f"Build {build_id} doesn't have a docker manifest", + } + return JSONResponse( status_code=400, - detail=f"Build {build_id} doesn't have a docker manifest", + content=content, + headers=response_headers )