File tree Expand file tree Collapse file tree 5 files changed +39
-26
lines changed
docs/reference/lang/codelab
i18n/zh-CN/docusaurus-plugin-content-docs
current/reference/lang/codelab
version-0.9/reference/lang/codelab
versioned_docs/version-0.9/reference/lang/codelab Expand file tree Collapse file tree 5 files changed +39
-26
lines changed Original file line number Diff line number Diff line change @@ -164,8 +164,6 @@ Suppose we have some schema logic, we can wrapper it into schema:
164164``` python
165165schema Deployment[priority]:
166166 name: str
167- cpu: int = _cpu
168- memory: int = _cpu * 2
169167 image: str
170168 service: " my-service" = " my-service"
171169 replica: int = 1
@@ -181,6 +179,9 @@ schema Deployment[priority]:
181179 _cpu = 1024
182180 else :
183181 _cpu = 2048
182+
183+ cpu: int = _cpu
184+ memory: int = _cpu * 2
184185```
185186
186187Now, we can define a config by creating a schema instance and pass in priority as an argument to schema:
@@ -227,8 +228,6 @@ Now we want to define a detailed schema with service and volumes, we can do it a
227228` ` ` python
228229schema Deployment[priority] :
229230 name : str
230- cpu : int = _cpu
231- memory : int = _cpu * 2
232231 volumes? : [Volume]
233232 image : str
234233 service? : Service
@@ -245,6 +244,9 @@ schema Deployment[priority]:
245244 else :
246245 _cpu = 2048
247246
247+ cpu : int = _cpu
248+ memory : int = _cpu * 2
249+
248250schema Port :
249251 name : str
250252 protocol : str
@@ -373,8 +375,6 @@ import regex
373375
374376schema Deployment[priority]:
375377 name: str
376- cpu: int = _cpu
377- memory: int = _cpu * 2
378378 volumes? : [Volume]
379379 image: str
380380 service? : Service
@@ -391,6 +391,9 @@ schema Deployment[priority]:
391391 else :
392392 _cpu = 2048
393393
394+ cpu: int = _cpu
395+ memory: int = _cpu * 2
396+
394397 check:
395398 multiplyof(cpu, 256 ), " cpu must be a multiplier of 256"
396399 regex.match(image, " ^[a-zA-Z]+:\d+\.\d+\.\d+$" ), " image name should be like 'nginx:1.14.2'"
Original file line number Diff line number Diff line change @@ -2,8 +2,6 @@ import regex
22
33schema Deployment[priority]:
44 name: str
5- cpu: int = _cpu
6- memory: int = _cpu * 2
75 volumes?: [Volume]
86 image: str
97 service?: Service
@@ -20,6 +18,9 @@ schema Deployment[priority]:
2018 else:
2119 _cpu = 2048
2220
21+ cpu: int = _cpu
22+ memory: int = _cpu * 2
23+
2324 check:
2425 multiplyof(cpu, 256), "cpu must be a multiplier of 256"
2526 regex.match(image, "^[a-zA-Z]+:\d+\.\d+\.\d+$"), "image name should be like 'nginx:1.14.2'"
Original file line number Diff line number Diff line change @@ -164,8 +164,6 @@ nginx = Deployment {
164164``` python
165165schema Deployment[priority]:
166166 name: str
167- cpu: int = _cpu
168- memory: int = _cpu * 2
169167 image: str
170168 service: " my-service" = " my-service"
171169 replica: int = 1
@@ -181,6 +179,9 @@ schema Deployment[priority]:
181179 _cpu = 1024
182180 else :
183181 _cpu = 2048
182+
183+ cpu: int = _cpu
184+ memory: int = _cpu * 2
184185```
185186
186187现在,我们可以通过创建 schema 实例来定义配置,并将优先级作为参数传递给模式:
@@ -227,8 +228,6 @@ nginx:
227228` ` ` python
228229schema Deployment[priority] :
229230 name : str
230- cpu : int = _cpu
231- memory : int = _cpu * 2
232231 volumes? : [Volume]
233232 image : str
234233 service? : Service
@@ -244,6 +243,9 @@ schema Deployment[priority]:
244243 _cpu = 1024
245244 else :
246245 _cpu = 2048
246+
247+ cpu : int = _cpu
248+ memory : int = _cpu * 2
247249
248250schema Port :
249251 name : str
@@ -373,8 +375,6 @@ import regex
373375
374376schema Deployment[priority]:
375377 name: str
376- cpu: int = _cpu
377- memory: int = _cpu * 2
378378 volumes? : [Volume]
379379 image: str
380380 service? : Service
@@ -391,6 +391,9 @@ schema Deployment[priority]:
391391 else :
392392 _cpu = 2048
393393
394+ cpu: int = _cpu
395+ memory: int = _cpu * 2
396+
394397 check:
395398 multiplyof(cpu, 256 ), " cpu must be a multiplier of 256"
396399 regex.match(image, " ^[a-zA-Z]+:\d+\.\d+\.\d+$" ), " image name should be like 'nginx:1.14.2'"
Original file line number Diff line number Diff line change @@ -164,8 +164,6 @@ nginx = Deployment {
164164``` python
165165schema Deployment[priority]:
166166 name: str
167- cpu: int = _cpu
168- memory: int = _cpu * 2
169167 image: str
170168 service: " my-service" = " my-service"
171169 replica: int = 1
@@ -181,6 +179,9 @@ schema Deployment[priority]:
181179 _cpu = 1024
182180 else :
183181 _cpu = 2048
182+
183+ cpu: int = _cpu
184+ memory: int = _cpu * 2
184185```
185186
186187现在,我们可以通过创建 schema 实例来定义配置,并将优先级作为参数传递给模式:
@@ -227,8 +228,6 @@ nginx:
227228` ` ` python
228229schema Deployment[priority] :
229230 name : str
230- cpu : int = _cpu
231- memory : int = _cpu * 2
232231 volumes? : [Volume]
233232 image : str
234233 service? : Service
@@ -244,6 +243,9 @@ schema Deployment[priority]:
244243 _cpu = 1024
245244 else :
246245 _cpu = 2048
246+
247+ cpu : int = _cpu
248+ memory : int = _cpu * 2
247249
248250schema Port :
249251 name : str
@@ -373,8 +375,6 @@ import regex
373375
374376schema Deployment[priority]:
375377 name: str
376- cpu: int = _cpu
377- memory: int = _cpu * 2
378378 volumes? : [Volume]
379379 image: str
380380 service? : Service
@@ -391,6 +391,9 @@ schema Deployment[priority]:
391391 else :
392392 _cpu = 2048
393393
394+ cpu: int = _cpu
395+ memory: int = _cpu * 2
396+
394397 check:
395398 multiplyof(cpu, 256 ), " cpu must be a multiplier of 256"
396399 regex.match(image, " ^[a-zA-Z]+:\d+\.\d+\.\d+$" ), " image name should be like 'nginx:1.14.2'"
Original file line number Diff line number Diff line change @@ -164,8 +164,6 @@ Suppose we have some schema logic, we can wrapper it into schema:
164164``` python
165165schema Deployment[priority]:
166166 name: str
167- cpu: int = _cpu
168- memory: int = _cpu * 2
169167 image: str
170168 service: " my-service" = " my-service"
171169 replica: int = 1
@@ -181,6 +179,9 @@ schema Deployment[priority]:
181179 _cpu = 1024
182180 else :
183181 _cpu = 2048
182+
183+ cpu: int = _cpu
184+ memory: int = _cpu * 2
184185```
185186
186187Now, we can define a config by creating a schema instance and pass in priority as an argument to schema:
@@ -227,8 +228,6 @@ Now we want to define a detailed schema with service and volumes, we can do it a
227228` ` ` python
228229schema Deployment[priority] :
229230 name : str
230- cpu : int = _cpu
231- memory : int = _cpu * 2
232231 volumes? : [Volume]
233232 image : str
234233 service? : Service
@@ -245,6 +244,9 @@ schema Deployment[priority]:
245244 else :
246245 _cpu = 2048
247246
247+ cpu : int = _cpu
248+ memory : int = _cpu * 2
249+
248250schema Port :
249251 name : str
250252 protocol : str
@@ -373,8 +375,6 @@ import regex
373375
374376schema Deployment[priority]:
375377 name: str
376- cpu: int = _cpu
377- memory: int = _cpu * 2
378378 volumes? : [Volume]
379379 image: str
380380 service? : Service
@@ -391,6 +391,9 @@ schema Deployment[priority]:
391391 else :
392392 _cpu = 2048
393393
394+ cpu: int = _cpu
395+ memory: int = _cpu * 2
396+
394397 check:
395398 multiplyof(cpu, 256 ), " cpu must be a multiplier of 256"
396399 regex.match(image, " ^[a-zA-Z]+:\d+\.\d+\.\d+$" ), " image name should be like 'nginx:1.14.2'"
You can’t perform that action at this time.
0 commit comments