From 12bc411746a1d01aa9b5a71620cb381235db37fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9on=20Kuchenbecker?= Date: Tue, 19 Nov 2024 08:12:08 +0000 Subject: [PATCH] Allow colon characters in bucket names --- .pyproject_generation/pyproject_custom.toml | 2 +- pyproject.toml | 2 +- src/hexkit/protocols/objstorage.py | 2 +- src/hexkit/providers/s3/provider.py | 4 ++++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.pyproject_generation/pyproject_custom.toml b/.pyproject_generation/pyproject_custom.toml index 65f5ceee..24caa985 100644 --- a/.pyproject_generation/pyproject_custom.toml +++ b/.pyproject_generation/pyproject_custom.toml @@ -1,6 +1,6 @@ [project] name = "hexkit" -version = "4.0.0" +version = "4.1.0" description = "A Toolkit for Building Microservices using the Hexagonal Architecture" requires-python = ">=3.9" classifiers = [ diff --git a/pyproject.toml b/pyproject.toml index b7e4c2c3..565f04e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ classifiers = [ "Intended Audience :: Developers", ] name = "hexkit" -version = "4.0.0" +version = "4.1.0" description = "A Toolkit for Building Microservices using the Hexagonal Architecture" dependencies = [ "pydantic >=2, <3", diff --git a/src/hexkit/protocols/objstorage.py b/src/hexkit/protocols/objstorage.py index fbaa3e91..5328740b 100644 --- a/src/hexkit/protocols/objstorage.py +++ b/src/hexkit/protocols/objstorage.py @@ -489,7 +489,7 @@ async def _delete_object(self, *, bucket_id: str, object_id: str) -> None: # (is typically only used by the protocol but may also be used in # provider-specific code or overwritten by the provider) - _re_bucket_id = re.compile(r"^[a-z0-9\-]{3,63}$") + _re_bucket_id = re.compile(r"^[:a-z0-9\-]{3,63}$") _re_bucket_id_msg = "must consist of 3-63 lowercase letters, digits or hyphens" @classmethod diff --git a/src/hexkit/providers/s3/provider.py b/src/hexkit/providers/s3/provider.py index 3e152c02..e9fe63b1 100644 --- a/src/hexkit/providers/s3/provider.py +++ b/src/hexkit/providers/s3/provider.py @@ -22,6 +22,7 @@ # ruff: noqa: PLR0913 import asyncio +import re from functools import lru_cache from pathlib import Path from typing import Any, Optional @@ -31,6 +32,7 @@ import botocore.config import botocore.configloader import botocore.exceptions +import botocore.handlers from boto3.s3.transfer import TransferConfig from pydantic import Field, SecretStr from pydantic_settings import BaseSettings @@ -39,6 +41,8 @@ from hexkit.utils import calc_part_size __all__ = ["ObjectStorageProtocol", "PresignedPostURL"] +# Allow colon character in bucket names to accommodate Ceph multi tenancy S3 +botocore.handlers.VALID_BUCKET = re.compile(r"^[:a-zA-Z0-9.\-_]{1,255}$") class S3Config(BaseSettings):