Skip to content

Commit

Permalink
fix: tour protocol examples
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Aug 22, 2024
1 parent 00ed11a commit fcad80f
Show file tree
Hide file tree
Showing 16 changed files with 120 additions and 120 deletions.
14 changes: 7 additions & 7 deletions docs/reference/lang/tour.md
Original file line number Diff line number Diff line change
Expand Up @@ -2700,26 +2700,26 @@ We can use protocol to implement type checking of rule structure:

```python
# Protocol definition
protocol Service:
protocol ServiceProtocol:
clusterIp: str
$type: str

# Protocol definition
protocol Volume:
mountPath: [str]
protocol VolumeProtocol:
mountPath: str

# Protocol
protocol SomeProtocol:
id: int
env: {str: any}
services: [Service]
volumes: [Volume]
services: [ServiceProtocol]
volumes: [VolumeProtocol]

rule SomeChecker for SomeProtocol:
id > 0, "id must >0"

all service in services {
service.clusterIP == "NONE" if service.type == "ClusterIP"
service.clusterIp == "NONE" if service.type == "ClusterIP"
}

any volume in volumes {
Expand All @@ -2735,7 +2735,7 @@ SomeChecker {
services = [
{
type = "ClusterIP"
clusterIP = "NONE"
clusterIp = "NONE"
}
]
volumes = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2633,26 +2633,26 @@ rule2 = SomeRule {}

```python
# Protocol definition
protocol Service:
protocol ServiceProtocol:
clusterIp: str
$type: str

# Protocol definition
protocol Volume:
mountPath: [str]
protocol VolumeProtocol:
mountPath: str

# Protocol
protocol SomeProtocol:
id: int
env: {str: any}
services: [Service]
volumes: [Volume]
services: [ServiceProtocol]
volumes: [VolumeProtocol]

rule SomeChecker for SomeProtocol:
id > 0, "id must >0"

all service in services {
service.clusterIP == "NONE" if service.type == "ClusterIP"
service.clusterIp == "NONE" if service.type == "ClusterIP"
}

any volume in volumes {
Expand All @@ -2668,7 +2668,7 @@ SomeChecker {
services = [
{
type = "ClusterIP"
clusterIP = "NONE"
clusterIp = "NONE"
}
]
volumes = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2633,26 +2633,26 @@ rule2 = SomeRule {}

```python
# Protocol definition
protocol Service:
protocol ServiceProtocol:
clusterIp: str
$type: str

# Protocol definition
protocol Volume:
mountPath: [str]
protocol VolumeProtocol:
mountPath: str

# Protocol
protocol SomeProtocol:
id: int
env: {str: any}
services: [Service]
volumes: [Volume]
services: [ServiceProtocol]
volumes: [VolumeProtocol]

rule SomeChecker for SomeProtocol:
id > 0, "id must >0"

all service in services {
service.clusterIP == "NONE" if service.type == "ClusterIP"
service.clusterIp == "NONE" if service.type == "ClusterIP"
}

any volume in volumes {
Expand All @@ -2668,7 +2668,7 @@ SomeChecker {
services = [
{
type = "ClusterIP"
clusterIP = "NONE"
clusterIp = "NONE"
}
]
volumes = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2558,27 +2558,27 @@ rule2 = SomeRule {}
可以使用 protocol 和 for 绑定语句为 rule 增加类型约束:

```python
# Schema definition
protocol Service:
# Protocol definition
protocol ServiceProtocol:
clusterIp: str
$type: str

# Schema definition
protocol Volume:
mountPath: [str]
# Protocol definition
protocol VolumeProtocol:
mountPath: str

# Protocol
protocol SomeProtocol:
id: int
env: {str: any}
services: [Service]
volumes: [Volume]
services: [ServiceProtocol]
volumes: [VolumeProtocol]

rule SomeChecker for SomeProtocol:
id > 0, "id must >0"

all service in services {
service.clusterIP == "NONE" if service.type == "ClusterIP"
service.clusterIp == "NONE" if service.type == "ClusterIP"
}

any volume in volumes {
Expand All @@ -2594,7 +2594,7 @@ SomeChecker {
services = [
{
type = "ClusterIP"
clusterIP = "NONE"
clusterIp = "NONE"
}
]
volumes = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2567,27 +2567,27 @@ rule2 = SomeRule {}
可以使用 protocol 和 for 绑定语句为 rule 增加类型约束:

```python
# Schema definition
protocol Service:
# Protocol definition
protocol ServiceProtocol:
clusterIp: str
$type: str

# Schema definition
protocol Volume:
mountPath: [str]
# Protocol definition
protocol VolumeProtocol:
mountPath: str

# Protocol
protocol SomeProtocol:
id: int
env: {str: any}
services: [Service]
volumes: [Volume]
services: [ServiceProtocol]
volumes: [VolumeProtocol]

rule SomeChecker for SomeProtocol:
id > 0, "id must >0"

all service in services {
service.clusterIP == "NONE" if service.type == "ClusterIP"
service.clusterIp == "NONE" if service.type == "ClusterIP"
}

any volume in volumes {
Expand All @@ -2603,7 +2603,7 @@ SomeChecker {
services = [
{
type = "ClusterIP"
clusterIP = "NONE"
clusterIp = "NONE"
}
]
volumes = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2609,26 +2609,26 @@ rule2 = SomeRule {}

```python
# Protocol definition
protocol Service:
protocol ServiceProtocol:
clusterIp: str
$type: str

# Protocol definition
protocol Volume:
mountPath: [str]
protocol VolumeProtocol:
mountPath: str

# Protocol
protocol SomeProtocol:
id: int
env: {str: any}
services: [Service]
volumes: [Volume]
services: [ServiceProtocol]
volumes: [VolumeProtocol]

rule SomeChecker for SomeProtocol:
id > 0, "id must >0"

all service in services {
service.clusterIP == "NONE" if service.type == "ClusterIP"
service.clusterIp == "NONE" if service.type == "ClusterIP"
}

any volume in volumes {
Expand All @@ -2644,7 +2644,7 @@ SomeChecker {
services = [
{
type = "ClusterIP"
clusterIP = "NONE"
clusterIp = "NONE"
}
]
volumes = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2623,26 +2623,26 @@ rule2 = SomeRule {}

```python
# Protocol definition
protocol Service:
protocol ServiceProtocol:
clusterIp: str
$type: str

# Protocol definition
protocol Volume:
mountPath: [str]
protocol VolumeProtocol:
mountPath: str

# Protocol
protocol SomeProtocol:
id: int
env: {str: any}
services: [Service]
volumes: [Volume]
services: [ServiceProtocol]
volumes: [VolumeProtocol]

rule SomeChecker for SomeProtocol:
id > 0, "id must >0"

all service in services {
service.clusterIP == "NONE" if service.type == "ClusterIP"
service.clusterIp == "NONE" if service.type == "ClusterIP"
}

any volume in volumes {
Expand All @@ -2658,7 +2658,7 @@ SomeChecker {
services = [
{
type = "ClusterIP"
clusterIP = "NONE"
clusterIp = "NONE"
}
]
volumes = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2623,26 +2623,26 @@ rule2 = SomeRule {}

```python
# Protocol definition
protocol Service:
protocol ServiceProtocol:
clusterIp: str
$type: str

# Protocol definition
protocol Volume:
mountPath: [str]
protocol VolumeProtocol:
mountPath: str

# Protocol
protocol SomeProtocol:
id: int
env: {str: any}
services: [Service]
volumes: [Volume]
services: [ServiceProtocol]
volumes: [VolumeProtocol]

rule SomeChecker for SomeProtocol:
id > 0, "id must >0"

all service in services {
service.clusterIP == "NONE" if service.type == "ClusterIP"
service.clusterIp == "NONE" if service.type == "ClusterIP"
}

any volume in volumes {
Expand All @@ -2658,7 +2658,7 @@ SomeChecker {
services = [
{
type = "ClusterIP"
clusterIP = "NONE"
clusterIp = "NONE"
}
]
volumes = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2633,26 +2633,26 @@ rule2 = SomeRule {}

```python
# Protocol definition
protocol Service:
protocol ServiceProtocol:
clusterIp: str
$type: str

# Protocol definition
protocol Volume:
mountPath: [str]
protocol VolumeProtocol:
mountPath: str

# Protocol
protocol SomeProtocol:
id: int
env: {str: any}
services: [Service]
volumes: [Volume]
services: [ServiceProtocol]
volumes: [VolumeProtocol]

rule SomeChecker for SomeProtocol:
id > 0, "id must >0"

all service in services {
service.clusterIP == "NONE" if service.type == "ClusterIP"
service.clusterIp == "NONE" if service.type == "ClusterIP"
}

any volume in volumes {
Expand All @@ -2668,7 +2668,7 @@ SomeChecker {
services = [
{
type = "ClusterIP"
clusterIP = "NONE"
clusterIp = "NONE"
}
]
volumes = [
Expand Down
Loading

0 comments on commit fcad80f

Please sign in to comment.