Skip to content

Commit

Permalink
feat: add type in schema Port to support multiple clouds (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
healthjyk authored Sep 15, 2023
1 parent a4116a9 commit d775fc0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions models/samples/helloworld/base/base.k
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ helloworld: ac.AppConfiguration {
replicas: 2
ports: [
n.Port {
type: "aliyun"
port: 80
targetPort: 8080
public: True
Expand Down
1 change: 1 addition & 0 deletions models/samples/wordpress/base/base.k
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ wordpress: ac.AppConfiguration {
replicas: 2
ports: [
n.Port {
type: "aliyun"
port: 80
public: True
}
Expand Down
8 changes: 7 additions & 1 deletion models/schema/v1/workload/network/port.k
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ schema Port:

Attributes
----------
type: "aliyun" | "aws", default is Undefined, optional.
The specific cloud vendor that provides load balancer, works when public is True.
port: int, default is 80, required.
The exposed port of the Service.
targetPort: int, default is Undefined, optional.
Expand All @@ -18,13 +20,17 @@ schema Port:
import models.schema.v1.workload.network as n

port = n.Port {
type: "aliyun"
port: 80
targetPort: 8080
protocol: "TCP"
public: True
}
"""

# The specific cloud vendor that provides load balancer, works when public is True.
type?: "aliyun" | "aws"

# The exposed port of the Service.
port: int = 80

Expand All @@ -37,7 +43,7 @@ schema Port:
# Public defines whether to expose the port through Internet.
public: bool = False


check:
type if public, "type must exist when public is True"
1 <= port <= 65535, "port must be between 1 and 65535, inclusive"
1 <= targetPort <= 65535 if targetPort, "targetPort must be between 1 and 65535, inclusive"

0 comments on commit d775fc0

Please sign in to comment.