mirror of
https://github.com/yavook/kiwi-scp.git
synced 2024-11-21 20:33:00 +00:00
config.py imports
This commit is contained in:
parent
370097e5c3
commit
af02c410e5
1 changed files with 10 additions and 10 deletions
|
@ -2,27 +2,27 @@ from ipaddress import IPv4Network
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional, Dict, List
|
from typing import Optional, Dict, List
|
||||||
|
|
||||||
import pydantic
|
from pydantic import BaseModel, constr, root_validator, validator
|
||||||
|
|
||||||
from ._constants import RE_SEMVER, RE_VARNAME
|
from ._constants import RE_SEMVER, RE_VARNAME
|
||||||
|
|
||||||
|
|
||||||
class _Storage(pydantic.BaseModel):
|
class _Storage(BaseModel):
|
||||||
"""a storage subsection"""
|
"""a storage subsection"""
|
||||||
|
|
||||||
directory: Path
|
directory: Path
|
||||||
|
|
||||||
|
|
||||||
class _Project(pydantic.BaseModel):
|
class _Project(BaseModel):
|
||||||
"""a project subsection"""
|
"""a project subsection"""
|
||||||
|
|
||||||
name: pydantic.constr(
|
name: constr(
|
||||||
regex=RE_VARNAME
|
regex=RE_VARNAME
|
||||||
)
|
)
|
||||||
enabled: bool = True
|
enabled: bool = True
|
||||||
override_storage: Optional[_Storage]
|
override_storage: Optional[_Storage]
|
||||||
|
|
||||||
@pydantic.root_validator(pre=True)
|
@root_validator(pre=True)
|
||||||
@classmethod
|
@classmethod
|
||||||
def unify_project(cls, values):
|
def unify_project(cls, values):
|
||||||
"""parse different project notations"""
|
"""parse different project notations"""
|
||||||
|
@ -46,20 +46,20 @@ class _Project(pydantic.BaseModel):
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
|
|
||||||
class _Network(pydantic.BaseModel):
|
class _Network(BaseModel):
|
||||||
"""a network subsection"""
|
"""a network subsection"""
|
||||||
|
|
||||||
name: pydantic.constr(
|
name: constr(
|
||||||
to_lower=True,
|
to_lower=True,
|
||||||
regex=RE_VARNAME
|
regex=RE_VARNAME
|
||||||
)
|
)
|
||||||
cidr: IPv4Network
|
cidr: IPv4Network
|
||||||
|
|
||||||
|
|
||||||
class Config(pydantic.BaseModel):
|
class Config(BaseModel):
|
||||||
"""represents a kiwi.yml"""
|
"""represents a kiwi.yml"""
|
||||||
|
|
||||||
version: pydantic.constr(
|
version: constr(
|
||||||
regex=RE_SEMVER
|
regex=RE_SEMVER
|
||||||
)
|
)
|
||||||
shells: Optional[List[str]]
|
shells: Optional[List[str]]
|
||||||
|
@ -69,7 +69,7 @@ class Config(pydantic.BaseModel):
|
||||||
storage: _Storage
|
storage: _Storage
|
||||||
network: _Network
|
network: _Network
|
||||||
|
|
||||||
@pydantic.validator("environment", pre=True)
|
@validator("environment", pre=True)
|
||||||
@classmethod
|
@classmethod
|
||||||
def unify_environment(cls, value) -> Optional[Dict[str, Optional[str]]]:
|
def unify_environment(cls, value) -> Optional[Dict[str, Optional[str]]]:
|
||||||
"""parse different environment notations"""
|
"""parse different environment notations"""
|
||||||
|
|
Loading…
Reference in a new issue