Skip to content

Commit 4e2126d

Browse files
committed
chore: update codelab examples
Signed-off-by: peefy <[email protected]>
1 parent 038bb84 commit 4e2126d

File tree

5 files changed

+39
-26
lines changed
  • docs/reference/lang/codelab
  • examples/codelab/schema
  • i18n/zh-CN/docusaurus-plugin-content-docs
  • versioned_docs/version-0.9/reference/lang/codelab

5 files changed

+39
-26
lines changed

docs/reference/lang/codelab/schema.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ Suppose we have some schema logic, we can wrapper it into schema:
164164
```python
165165
schema 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
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
227228
```python
228229
schema 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+
248250
schema Port:
249251
name: str
250252
protocol: str
@@ -373,8 +375,6 @@ import regex
373375

374376
schema 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'"

examples/codelab/schema/my_config.k

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import regex
22

33
schema 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'"

i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/lang/codelab/schema.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ nginx = Deployment {
164164
```python
165165
schema 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
228229
schema 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

248250
schema Port:
249251
name: str
@@ -373,8 +375,6 @@ import regex
373375

374376
schema 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'"

i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/lang/codelab/schema.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ nginx = Deployment {
164164
```python
165165
schema 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
228229
schema 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

248250
schema Port:
249251
name: str
@@ -373,8 +375,6 @@ import regex
373375

374376
schema 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'"

versioned_docs/version-0.9/reference/lang/codelab/schema.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ Suppose we have some schema logic, we can wrapper it into schema:
164164
```python
165165
schema 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
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
227228
```python
228229
schema 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+
248250
schema Port:
249251
name: str
250252
protocol: str
@@ -373,8 +375,6 @@ import regex
373375

374376
schema 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'"

0 commit comments

Comments
 (0)