Skip to content

Commit e0d3c53

Browse files
authored
Merge pull request #3798 from camptocamp/use-c2casgiutils-route-prefix
Use c2casgiutils route_prefix instead of tilecloud-chain's own
2 parents 3f72062 + 52ddfb1 commit e0d3c53

10 files changed

Lines changed: 18 additions & 24 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 2.0.1
4+
5+
- Replace `TILECLOUD_CHAIN__ROUTE_PREFIX` with `C2C__ROUTE_PREFIX` (from c2casgiutils) for the route prefix environment variable. The default remains `/tiles/` when using the Docker image.
6+
37
## 2.0.0
48

59
- Add a read-only mode to the admin interface: the configured `authentication.github_access_type` grants read-write access, while users with only a `pull` access on the configured `authentication.github_repository` can see the status and jobs but cannot start, cancel or retry generations.

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ RUN --mount=type=cache,target=/var/lib/apt/lists \
2020
&& python3 -m venv --system-site-packages /venv
2121

2222
ENV PATH=/venv/bin:$PATH
23+
ENV C2C__ROUTE_PREFIX=/tiles/
2324

2425
# Used to convert the locked packages by poetry to pip requirements format
2526
# We don't directly use `poetry install` because it force to use a virtual environment.

tilecloud_chain/CONFIG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@
314314
- <a id="definitions/server/properties/geoms_redirect"></a>**`geoms_redirect`** *(boolean)*: Take care on the geometries. Default: `false`.
315315
- <a id="definitions/server/properties/static_allow_extension"></a>**`static_allow_extension`** *(array)*: The allowed extension of static files. Default: `["jpeg", "png", "xml", "js", "html", "css"]`.
316316
- <a id="definitions/server/properties/static_allow_extension/items"></a>**Items** *(string)*
317-
- <a id="definitions/server/properties/wmts_path"></a>**`wmts_path`** *(string)*: No longer used, replaced by `TILECLOUD_CHAIN__ROUTE_PREFIX` or `TILECLOUD_CHAIN__WMTS_PATH` environment variable.
317+
- <a id="definitions/server/properties/wmts_path"></a>**`wmts_path`** *(string)*: No longer used, replaced by `C2C__ROUTE_PREFIX` or `TILECLOUD_CHAIN__WMTS_PATH` environment variable.
318318
- <a id="definitions/server/properties/admin_path"></a>**`admin_path`** *(string)*: No longer used.
319319
- <a id="definitions/server/properties/static_path"></a>**`static_path`** *(string)*: No longer used.
320320
- <a id="definitions/server/properties/expires"></a>**`expires`** *(integer)*: The browser cache expiration in hours. Default: `8`.

tilecloud_chain/USAGE.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -886,11 +886,11 @@ Server:
886886
- ``TILECLOUD_CHAIN__DEVELOPMENT``: Enable development features if set to ``true``
887887
(default: ``false``)
888888

889-
- ``TILECLOUD_CHAIN__ROUTE_PREFIX``: Base URL path for tile access
890-
(default: ``/tiles/``)
889+
- ``C2C__ROUTE_PREFIX``: Base URL path for tile access
890+
(default: ``/tiles/``, provided by c2casgiutils)
891891

892892
- ``TILECLOUD_CHAIN__WMTS_PATH``: Path used in WMTS capabilities URLs, overrides the route prefix
893-
(default: the value of ``TILECLOUD_CHAIN__ROUTE_PREFIX`` without a leading ``/``)
893+
(default: the value of ``C2C__ROUTE_PREFIX`` without a leading ``/``)
894894

895895
Worker:
896896

tilecloud_chain/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2970,7 +2970,7 @@ class Server(TypedDict, total=False):
29702970
r"""
29712971
WMTS path.
29722972
2973-
No longer used, replaced by `TILECLOUD_CHAIN__ROUTE_PREFIX` or `TILECLOUD_CHAIN__WMTS_PATH` environment variable
2973+
No longer used, replaced by `C2C__ROUTE_PREFIX` or `TILECLOUD_CHAIN__WMTS_PATH` environment variable
29742974
"""
29752975

29762976
admin_path: str

tilecloud_chain/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ async def _lifespan(main_app: FastAPI) -> AsyncGenerator[None, None]:
110110
allow_headers=settings.security.cors_headers,
111111
)
112112

113-
route_prefix = settings.route_prefix
113+
route_prefix = c2c_settings.route_prefix
114114
route_prefix_escaped = re.escape(route_prefix[1:])
115115

116116
_LOGGER.info("Using route prefix: '%s'", route_prefix)

tilecloud_chain/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@
11881188
},
11891189
"wmts_path": {
11901190
"title": "WMTS path",
1191-
"description": "No longer used, replaced by `TILECLOUD_CHAIN__ROUTE_PREFIX` or `TILECLOUD_CHAIN__WMTS_PATH` environment variable",
1191+
"description": "No longer used, replaced by `C2C__ROUTE_PREFIX` or `TILECLOUD_CHAIN__WMTS_PATH` environment variable",
11921192
"type": "string"
11931193
},
11941194
"admin_path": {

tilecloud_chain/server.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import yaml
4848
from anyio import Path
4949
from azure.core.exceptions import ResourceNotFoundError
50+
from c2casgiutils.config import settings as c2c_settings
5051
from fastapi import FastAPI, HTTPException, Query, Request
5152
from fastapi.responses import Response
5253
from fastapi.templating import Jinja2Templates
@@ -522,7 +523,9 @@ async def serve(
522523
)
523524
server_config = (await _TILEGENERATION.get_main_config()).config.get("server")
524525

525-
wmts_path = settings.route_prefix[1:] if settings.wmts_path is None else settings.wmts_path
526+
wmts_path = (
527+
c2c_settings.route_prefix[1:] if settings.wmts_path is None else settings.wmts_path
528+
)
526529

527530
base_urls = _get_base_urls(cache)
528531

@@ -849,7 +852,7 @@ def error(
849852
server = Server()
850853
router = fastapi.APIRouter()
851854

852-
route_prefix = settings.route_prefix
855+
route_prefix = c2c_settings.route_prefix
853856

854857

855858
async def startup(_main_app: FastAPI) -> None:

tilecloud_chain/settings.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,6 @@ def _to_str_list(value: str | list[str] | None) -> list[str]:
4040
StrList = Annotated[list[str], BeforeValidator(_to_str_list)]
4141

4242

43-
def _to_route_prefix(route_prefix: str) -> str:
44-
if not route_prefix:
45-
return "/"
46-
if not route_prefix.startswith("/"):
47-
route_prefix = f"/{route_prefix}"
48-
if not route_prefix.endswith("/"):
49-
route_prefix = f"{route_prefix}/"
50-
return route_prefix
51-
52-
53-
RoutePrefix = Annotated[str, BeforeValidator(_to_route_prefix)]
54-
55-
5643
def _to_wmts_path(wmts_path: str | None) -> str | None:
5744
if wmts_path is None:
5845
return None
@@ -154,7 +141,6 @@ class Settings(BaseSettings):
154141
allowed_process_commands: StrList = ["optipng", "jpegoptim", "pngquant"]
155142
frontend: str | None = None
156143
development: bool = False
157-
route_prefix: RoutePrefix = "/tiles/"
158144
wmts_path: WmtsPath = None
159145

160146
azure: AzureSettings = AzureSettings()

tilecloud_chain/views/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ async def admin_index(
271271
"current_url": str(request.url),
272272
"commands": server_config.get("predefined_commands", []),
273273
"status": await get_status(gene) if queue_store != "postgresql" else None,
274-
"admin_path": f"{settings.route_prefix}admin",
274+
"admin_path": f"{c2c_config.settings.route_prefix}admin",
275275
"AuthenticationType": auth.AuthenticationType,
276276
"jobs_status": jobs_status,
277277
"footer": main_server_config.get("admin_footer") if has_access else None,

0 commit comments

Comments
 (0)