Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tour protocol examples #448

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading