-
Notifications
You must be signed in to change notification settings - Fork 1
/
models.py
171 lines (130 loc) · 3.66 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
from enum import Enum
from typing import List, Optional, Union
from pydantic import BaseModel, Field
class VolumeMount(BaseModel):
"""volume mount object"""
name: str
mount_path: str = Field(serialization_alias="mountPath")
sub_path: Union[str, None] = Field(default=None, serialization_alias="subPath")
class Volume(BaseModel):
"""
class defining a volume object:
name: volume-workspace
claimName: claim-workspace
size: 10Gi
storage_class: "scw-bssd"
access_modes:
- "ReadWriteOnce"
volume_mount:
name: volume-workspace
mountPath: "/workspace"
persist: true
"""
name: str
claim_name: str
size: str
storage_class: str
access_modes: List[str]
volume_mount: VolumeMount
persist: bool
class ConfigMap(BaseModel):
"""
name: aws-credentials
key: aws-credentials
mountPath: /home/jovyan/.aws/credentials
defaultMode: 0660
readOnly: true
content: |
"""
name: str
key: str
mount_path: str
default_mode: Optional[str]
readonly: bool
content: Optional[str] = None
persist: Optional[bool] = True
class KubespawnerOverride(BaseModel):
cpu_limit: int
cpu_guarantee: Optional[int] = None
mem_limit: str
mem_guarantee: Optional[str] = None
image: str
extra_resource_limits: Optional[dict] = {}
extra_resource_guarantees: Optional[dict] = {}
class InitContainer(BaseModel):
name: str
image: str
command: List[str]
volume_mounts: List[VolumeMount]
# {
# "name": "init-file-on-volume",
# "image": "bitnami/git:latest",
# "command": ["sh", "-c", "sh -x /opt/init/.init.sh"],
# "volumeMounts": [
# {"name": "workspace-volume", "mountPath": "/workspace"},
# {"name": "init", "subPath": "init", "mountPath": "/opt/init/.init.sh"},
# ],
# }
class ProfileDefinition(BaseModel):
"""
display_name: Profile 2
slug: profile_2_slug
default: False
kubespawner_override:
cpu_limit: 4
mem_limit: 8G
image: eoepca/pde-code-server:develop
"""
display_name: str
description: Optional[str] = None
slug: str
default: bool
kubespawner_override: KubespawnerOverride
class ConfigMapKeyRef(BaseModel):
name: str
key: str
class ConfigMapEnvVarReference(BaseModel):
from_config_map: ConfigMapKeyRef
class SubjectKind(str, Enum):
service_account = "ServiceAccount"
user = "User"
class Verb(str, Enum):
get = "get"
list = "list"
watch = "watch"
create = "create"
update = "update"
patch = "patch"
delete = "delete"
deletecollection = "deletecollection"
class Subject(BaseModel):
name: str
kind: SubjectKind
class Role(BaseModel):
name: str
resources: List[str]
verbs: List[Verb]
api_groups: Optional[List[str]] = [""]
class RoleBinding(BaseModel):
name: str
subjects: List[Subject]
role: Role
persist: bool = True
class ImagePullSecret(BaseModel):
name: str
persist: bool = True
data: Optional[str] = None
class Profile(BaseModel):
id: str
groups: List[str]
definition: ProfileDefinition
config_maps: Optional[List[ConfigMap]] = None
volumes: Optional[List[Volume]] = None
pod_env_vars: Optional[dict[str, Union[str, ConfigMapEnvVarReference]]] = None
default_url: Optional[str] = None
node_selector: dict
role_bindings: Optional[List[RoleBinding]] = None
image_pull_secrets: Optional[List[ImagePullSecret]] = None
init_containers: Optional[List[InitContainer]] = None
class Config(BaseModel):
profiles: List[Profile]