File tree Expand file tree Collapse file tree 5 files changed +238
-126
lines changed Expand file tree Collapse file tree 5 files changed +238
-126
lines changed Original file line number Diff line number Diff line change @@ -105,3 +105,4 @@ venv.bak/
105105
106106# mypy
107107.mypy_cache /
108+ .idea
Original file line number Diff line number Diff line change 66
77from docker import DockerClient
88
9+ from app .types import ConfigChallengeType , ConfigDockerHostType
10+
911
1012try :
1113 DEBUG = strtobool (getenv ("DEBUG" , "0" ))
3133 MIN_PORTS = config ["random_ports" ]["min" ]
3234 MAX_PORTS = config ["random_ports" ]["max" ]
3335
34- CHALLENGES = config ["challenges" ]
35- DOCKER_HOSTS = config ["hosts" ]
36+ CHALLENGES : list [ ConfigChallengeType ] = config ["challenges" ]
37+ DOCKER_HOSTS : list [ ConfigDockerHostType ] = config ["hosts" ]
3638
3739 for host in DOCKER_HOSTS :
3840 host ["client" ] = DockerClient (base_url = host ["api" ])
Original file line number Diff line number Diff line change 11import typing
22
3+ from docker import DockerClient
4+
35
46class UserType (typing .TypedDict ):
57 user_id : int | None
@@ -9,3 +11,36 @@ class UserType(typing.TypedDict):
911 team_name : str | None
1012
1113 is_admin : bool
14+
15+
16+ class ConfigDockerHostType (typing .TypedDict ):
17+ domain : str
18+ api : str
19+ client : DockerClient
20+
21+
22+ class ContainerPortType (typing .TypedDict ):
23+ port : str
24+ protocol : typing .Literal ["http" , "ssh" ]
25+
26+
27+ class ChallengeContainerType (typing .TypedDict ):
28+ docker_image : str
29+
30+ hostname : str | None
31+ ports : list [ContainerPortType ]
32+
33+ command : str | None
34+ environment : dict [str , typing .Any ] | None
35+ privileged : bool | None
36+
37+ mem_limit : str
38+ read_only : bool
39+
40+ cpu_period : int | None
41+ cpu_quota : int | None
42+
43+
44+ class ConfigChallengeType (typing .TypedDict ):
45+ name : str
46+ containers : list [ChallengeContainerType ]
You can’t perform that action at this time.
0 commit comments