|
3 | 3 | from models_library.basic_regex import SIMPLE_VERSION_RE |
4 | 4 | from models_library.services import ServiceMetaDataPublished |
5 | 5 | from packaging import version |
6 | | -from pydantic import BaseModel, ByteSize, ConfigDict, Field, field_validator |
| 6 | +from pydantic import BaseModel, ByteSize, ConfigDict, Field, ValidationInfo, field_validator |
7 | 7 |
|
8 | 8 | LEGACY_INTEGRATION_VERSION = version.Version("0") |
9 | 9 | PROGRESS_REGEXP: re.Pattern[str] = re.compile( |
@@ -44,16 +44,16 @@ class ContainerHostConfig(BaseModel): |
44 | 44 |
|
45 | 45 | @field_validator("memory_swap", mode="before") |
46 | 46 | @classmethod |
47 | | - def ensure_no_memory_swap_means_no_swap(cls, v, values): |
| 47 | + def ensure_no_memory_swap_means_no_swap(cls, v, info: ValidationInfo): |
48 | 48 | if v is None: |
49 | 49 | # if not set it will be the same value as memory to ensure swap is disabled |
50 | | - return values["memory"] |
| 50 | + return info.data["memory"] |
51 | 51 | return v |
52 | 52 |
|
53 | 53 | @field_validator("memory_swap") |
54 | 54 | @classmethod |
55 | | - def ensure_memory_swap_cannot_be_unlimited_nor_smaller_than_memory(cls, v, values): |
56 | | - if v < values["memory"]: |
| 55 | + def ensure_memory_swap_cannot_be_unlimited_nor_smaller_than_memory(cls, v, info: ValidationInfo): |
| 56 | + if v < info.data["memory"]: |
57 | 57 | msg = "Memory swap cannot be set to a smaller value than memory" |
58 | 58 | raise ValueError(msg) |
59 | 59 | return v |
|
0 commit comments