|
1 | 1 | from functools import cached_property |
2 | | -from typing import Any, Self |
| 2 | +from typing import Annotated, Any, Self |
3 | 3 |
|
4 | 4 | from pydantic import ( |
5 | 5 | AnyHttpUrl, |
|
15 | 15 |
|
16 | 16 |
|
17 | 17 | class RegistrySettings(BaseCustomSettings): |
18 | | - REGISTRY_AUTH: bool = Field(..., description="do registry authentication") |
19 | | - REGISTRY_PATH: str | None = Field( |
20 | | - default=None, |
21 | | - # This is useful in case of a local registry, where the registry url (path) is relative to the host docker engine" |
22 | | - description="development mode only, in case a local registry is used - " |
23 | | - "this is the hostname to the docker registry as seen from the host running the containers (e.g. 127.0.0.1:5000)", |
24 | | - ) |
25 | | - # NOTE: name is missleading, http or https protocol are not included |
26 | | - REGISTRY_URL: str = Field( |
27 | | - ..., |
28 | | - description="hostname of docker registry (without protocol but with port if available)", |
29 | | - min_length=1, |
30 | | - ) |
| 18 | + REGISTRY_AUTH: Annotated[bool, Field(description="do registry authentication")] |
| 19 | + REGISTRY_PATH: Annotated[ |
| 20 | + str | None, |
| 21 | + Field( |
| 22 | + # This is useful in case of a local registry, where the registry url (path) is relative to the host docker engine" |
| 23 | + description="development mode only, in case a local registry is used - " |
| 24 | + "this is the hostname to the docker registry as seen from the host running the containers (e.g. 127.0.0.1:5000)", |
| 25 | + ), |
| 26 | + ] = None |
31 | 27 |
|
32 | | - REGISTRY_USER: str = Field( |
33 | | - ..., description="username to access the docker registry" |
34 | | - ) |
35 | | - REGISTRY_PW: SecretStr = Field( |
36 | | - ..., description="password to access the docker registry" |
37 | | - ) |
38 | | - REGISTRY_SSL: bool = Field( |
39 | | - ..., description="True if docker registry is using HTTPS protocol" |
40 | | - ) |
| 28 | + REGISTRY_URL: Annotated[ |
| 29 | + str, |
| 30 | + Field( |
| 31 | + # NOTE: name is missleading, http or https protocol are not included |
| 32 | + description="hostname of docker registry (without protocol but with port if available)", |
| 33 | + min_length=1, |
| 34 | + ), |
| 35 | + ] |
| 36 | + |
| 37 | + REGISTRY_USER: Annotated[ |
| 38 | + str, |
| 39 | + Field(description="username to access the docker registry"), |
| 40 | + ] |
| 41 | + REGISTRY_PW: Annotated[ |
| 42 | + SecretStr, |
| 43 | + Field(description="password to access the docker registry"), |
| 44 | + ] |
| 45 | + REGISTRY_SSL: Annotated[ |
| 46 | + bool, |
| 47 | + Field(description="True if docker registry is using HTTPS protocol"), |
| 48 | + ] |
41 | 49 |
|
42 | 50 | @field_validator("REGISTRY_PATH", mode="before") |
43 | 51 | @classmethod |
44 | 52 | def _escape_none_string(cls, v) -> Any | None: |
45 | 53 | return None if v == "None" else v |
46 | 54 |
|
47 | 55 | @model_validator(mode="after") |
48 | | - def check_registry_authentication(self: Self) -> Self: |
| 56 | + def _check_registry_authentication(self: Self) -> Self: |
49 | 57 | if self.REGISTRY_AUTH and any( |
50 | 58 | not v for v in (self.REGISTRY_USER, self.REGISTRY_PW) |
51 | 59 | ): |
|
0 commit comments