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:
164
164
``` python
165
165
schema Deployment[priority]:
166
166
name: str
167
- cpu: int = _cpu
168
- memory: int = _cpu * 2
169
167
image: str
170
168
service: " my-service" = " my-service"
171
169
replica: int = 1
@@ -181,6 +179,9 @@ schema Deployment[priority]:
181
179
_cpu = 1024
182
180
else :
183
181
_cpu = 2048
182
+
183
+ cpu: int = _cpu
184
+ memory: int = _cpu * 2
184
185
```
185
186
186
187
Now, 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
227
228
` ` ` python
228
229
schema Deployment[priority] :
229
230
name : str
230
- cpu : int = _cpu
231
- memory : int = _cpu * 2
232
231
volumes? : [Volume]
233
232
image : str
234
233
service? : Service
@@ -245,6 +244,9 @@ schema Deployment[priority]:
245
244
else :
246
245
_cpu = 2048
247
246
247
+ cpu : int = _cpu
248
+ memory : int = _cpu * 2
249
+
248
250
schema Port :
249
251
name : str
250
252
protocol : str
@@ -373,8 +375,6 @@ import regex
373
375
374
376
schema Deployment[priority]:
375
377
name: str
376
- cpu: int = _cpu
377
- memory: int = _cpu * 2
378
378
volumes? : [Volume]
379
379
image: str
380
380
service? : Service
@@ -391,6 +391,9 @@ schema Deployment[priority]:
391
391
else :
392
392
_cpu = 2048
393
393
394
+ cpu: int = _cpu
395
+ memory: int = _cpu * 2
396
+
394
397
check:
395
398
multiplyof(cpu, 256 ), " cpu must be a multiplier of 256"
396
399
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
2
2
3
3
schema Deployment[priority]:
4
4
name: str
5
- cpu: int = _cpu
6
- memory: int = _cpu * 2
7
5
volumes?: [Volume]
8
6
image: str
9
7
service?: Service
@@ -20,6 +18,9 @@ schema Deployment[priority]:
20
18
else:
21
19
_cpu = 2048
22
20
21
+ cpu: int = _cpu
22
+ memory: int = _cpu * 2
23
+
23
24
check:
24
25
multiplyof(cpu, 256), "cpu must be a multiplier of 256"
25
26
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 {
164
164
``` python
165
165
schema Deployment[priority]:
166
166
name: str
167
- cpu: int = _cpu
168
- memory: int = _cpu * 2
169
167
image: str
170
168
service: " my-service" = " my-service"
171
169
replica: int = 1
@@ -181,6 +179,9 @@ schema Deployment[priority]:
181
179
_cpu = 1024
182
180
else :
183
181
_cpu = 2048
182
+
183
+ cpu: int = _cpu
184
+ memory: int = _cpu * 2
184
185
```
185
186
186
187
现在,我们可以通过创建 schema 实例来定义配置,并将优先级作为参数传递给模式:
@@ -227,8 +228,6 @@ nginx:
227
228
` ` ` python
228
229
schema Deployment[priority] :
229
230
name : str
230
- cpu : int = _cpu
231
- memory : int = _cpu * 2
232
231
volumes? : [Volume]
233
232
image : str
234
233
service? : Service
@@ -244,6 +243,9 @@ schema Deployment[priority]:
244
243
_cpu = 1024
245
244
else :
246
245
_cpu = 2048
246
+
247
+ cpu : int = _cpu
248
+ memory : int = _cpu * 2
247
249
248
250
schema Port :
249
251
name : str
@@ -373,8 +375,6 @@ import regex
373
375
374
376
schema Deployment[priority]:
375
377
name: str
376
- cpu: int = _cpu
377
- memory: int = _cpu * 2
378
378
volumes? : [Volume]
379
379
image: str
380
380
service? : Service
@@ -391,6 +391,9 @@ schema Deployment[priority]:
391
391
else :
392
392
_cpu = 2048
393
393
394
+ cpu: int = _cpu
395
+ memory: int = _cpu * 2
396
+
394
397
check:
395
398
multiplyof(cpu, 256 ), " cpu must be a multiplier of 256"
396
399
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 {
164
164
``` python
165
165
schema Deployment[priority]:
166
166
name: str
167
- cpu: int = _cpu
168
- memory: int = _cpu * 2
169
167
image: str
170
168
service: " my-service" = " my-service"
171
169
replica: int = 1
@@ -181,6 +179,9 @@ schema Deployment[priority]:
181
179
_cpu = 1024
182
180
else :
183
181
_cpu = 2048
182
+
183
+ cpu: int = _cpu
184
+ memory: int = _cpu * 2
184
185
```
185
186
186
187
现在,我们可以通过创建 schema 实例来定义配置,并将优先级作为参数传递给模式:
@@ -227,8 +228,6 @@ nginx:
227
228
` ` ` python
228
229
schema Deployment[priority] :
229
230
name : str
230
- cpu : int = _cpu
231
- memory : int = _cpu * 2
232
231
volumes? : [Volume]
233
232
image : str
234
233
service? : Service
@@ -244,6 +243,9 @@ schema Deployment[priority]:
244
243
_cpu = 1024
245
244
else :
246
245
_cpu = 2048
246
+
247
+ cpu : int = _cpu
248
+ memory : int = _cpu * 2
247
249
248
250
schema Port :
249
251
name : str
@@ -373,8 +375,6 @@ import regex
373
375
374
376
schema Deployment[priority]:
375
377
name: str
376
- cpu: int = _cpu
377
- memory: int = _cpu * 2
378
378
volumes? : [Volume]
379
379
image: str
380
380
service? : Service
@@ -391,6 +391,9 @@ schema Deployment[priority]:
391
391
else :
392
392
_cpu = 2048
393
393
394
+ cpu: int = _cpu
395
+ memory: int = _cpu * 2
396
+
394
397
check:
395
398
multiplyof(cpu, 256 ), " cpu must be a multiplier of 256"
396
399
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:
164
164
``` python
165
165
schema Deployment[priority]:
166
166
name: str
167
- cpu: int = _cpu
168
- memory: int = _cpu * 2
169
167
image: str
170
168
service: " my-service" = " my-service"
171
169
replica: int = 1
@@ -181,6 +179,9 @@ schema Deployment[priority]:
181
179
_cpu = 1024
182
180
else :
183
181
_cpu = 2048
182
+
183
+ cpu: int = _cpu
184
+ memory: int = _cpu * 2
184
185
```
185
186
186
187
Now, 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
227
228
` ` ` python
228
229
schema Deployment[priority] :
229
230
name : str
230
- cpu : int = _cpu
231
- memory : int = _cpu * 2
232
231
volumes? : [Volume]
233
232
image : str
234
233
service? : Service
@@ -245,6 +244,9 @@ schema Deployment[priority]:
245
244
else :
246
245
_cpu = 2048
247
246
247
+ cpu : int = _cpu
248
+ memory : int = _cpu * 2
249
+
248
250
schema Port :
249
251
name : str
250
252
protocol : str
@@ -373,8 +375,6 @@ import regex
373
375
374
376
schema Deployment[priority]:
375
377
name: str
376
- cpu: int = _cpu
377
- memory: int = _cpu * 2
378
378
volumes? : [Volume]
379
379
image: str
380
380
service? : Service
@@ -391,6 +391,9 @@ schema Deployment[priority]:
391
391
else :
392
392
_cpu = 2048
393
393
394
+ cpu: int = _cpu
395
+ memory: int = _cpu * 2
396
+
394
397
check:
395
398
multiplyof(cpu, 256 ), " cpu must be a multiplier of 256"
396
399
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