Skip to content

Commit

Permalink
Deprecate api endpoint /build/<build id>/docker
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
soapy1 committed Nov 26, 2024
1 parent 5a9c53e commit d9a4a66
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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
)


Expand Down

0 comments on commit d9a4a66

Please sign in to comment.