Skip to content

Commit

Permalink
[pre-commit.ci] Apply automatic pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Dec 17, 2024
1 parent 24b74fe commit f75b803
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ class CondaStoreServer(Application):
)

enable_registry = Bool(
False, help="(deprecated) enable the docker registry for conda-store", config=True
False,
help="(deprecated) enable the docker registry for conda-store",
config=True,
)

enable_metrics = Bool(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# license that can be found in the LICENSE file.

import datetime
from functools import wraps
from typing import Any, Dict, List, Optional, TypedDict

import pydantic
import yaml
from celery.result import AsyncResult
from fastapi import APIRouter, Body, Depends, HTTPException, Query, Request
from fastapi.responses import JSONResponse, PlainTextResponse, RedirectResponse
from functools import wraps

from conda_store_server import __version__, api, app
from conda_store_server._internal import orm, schema, utils
Expand Down Expand Up @@ -128,6 +128,7 @@ def paginated_api_response(
"count": count,
}


def deprecated(sunset_date):
"""
Decorator to add deprecation headers to a response. These will include
Expand All @@ -138,14 +139,17 @@ def deprecated(sunset_date):
:param sunset_date: the sunset date in HTTP-Date format, for example "Mon, 16 Feb 2025 23:59:59 UTC"
"""

def decorator(func):
@wraps(func)
def add_deprecated_headers(*args, **kwargs):
response = func(*args, **kwargs)
response.headers["Deprecation"] = "True"
response.headers["Sunset"] = sunset_date
return response

return add_deprecated_headers

return decorator


Expand Down Expand Up @@ -1389,7 +1393,8 @@ async def api_get_build_docker_image_url(
"message": f"Build {build_id} doesn't have a docker manifest",
}
return JSONResponse(
status_code=400, content=content,
status_code=400,
content=content,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from fastapi.responses import RedirectResponse, Response

from conda_store_server import api
from conda_store_server._internal.server.views.api import deprecated
from conda_store_server._internal import orm, schema
from conda_store_server._internal.schema import Permissions
from conda_store_server._internal.server import dependencies
from conda_store_server._internal.server.views.api import deprecated

router_registry = APIRouter(tags=["registry"])

Expand Down Expand Up @@ -77,6 +77,7 @@ def replace_words(s, words):
)
return environment_name


@deprecated(sunset_date="Mon, 16 Feb 2025 23:59:59 UTC")
def get_docker_image_manifest(conda_store, image, tag, timeout=10 * 60):
namespace, *image_name = image.split("/")
Expand Down Expand Up @@ -133,6 +134,7 @@ def get_docker_image_blob(conda_store, image, blobsum):
blob_key = f"docker/blobs/{blobsum}"
return RedirectResponse(conda_store.storage.get_url(blob_key))


@router_registry.get("/v2/", deprecated=True)
@deprecated(sunset_date="Mon, 16 Feb 2025 23:59:59 UTC")
def v2(
Expand All @@ -145,9 +147,7 @@ def v2(
return _json_response({})


@router_registry.get(
"/v2/{rest:path}", deprecated=True
)
@router_registry.get("/v2/{rest:path}", deprecated=True)
@deprecated(sunset_date="Mon, 16 Feb 2025 23:59:59 UTC")
def list_tags(
rest: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ bindings that an authenticated user assumes.
`Authentication.cookie_name` is the name for the browser cookie used
to authenticate users.

`Authentication.cookie_domain` use when wanting to set a subdomain wide
cookie. For example setting this to `example.com` would allow the cookie
`Authentication.cookie_domain` use when wanting to set a subdomain wide
cookie. For example setting this to `example.com` would allow the cookie
to be valid for `example.com` along with `*.example.com`.

`Authentication.authentication_backend` is the class to use for
Expand Down Expand Up @@ -486,10 +486,10 @@ is a regular python fastapi function.

#### Deprecated configuration options for `conda_store_server._internal.server.app.CondaStoreServer`

`CondaStoreServer.enable_registry` (deprecated) a Boolean on whether to
`CondaStoreServer.enable_registry` (deprecated) a Boolean on whether to
expose the registry endpoints. Default False.

`CondaStoreServer.registry_external_url` (deprecated) is the external hostname
`CondaStoreServer.registry_external_url` (deprecated) is the external hostname
and port to access docker registry cannot contain `http://` or `https://`.

### `conda_store_server._internal.worker.app.CondaStoreWorker`
Expand Down

0 comments on commit f75b803

Please sign in to comment.