Skip to content

Commit

Permalink
feat(gateway): update gateway crds and rename pkg/string.go (#303)
Browse files Browse the repository at this point in the history
* feat(gateway): update gateway crds

* feat: rename pkg/string.go to pkg/slice.go

* feat: rename pkg/string.go to pkg/slice.go
  • Loading branch information
skyoct authored Aug 31, 2022
1 parent fe25ee8 commit 6f2d672
Show file tree
Hide file tree
Showing 7 changed files with 409 additions and 20 deletions.
48 changes: 47 additions & 1 deletion controllers/gateway/api/v1/gateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,59 @@ type GatewaySpec struct {
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of Gateway. Edit gateway_types.go to remove/update
Foo string `json:"foo,omitempty"`

// AppId是应用id,字母数字组成,长度5至16位,必须存在
// +kubebuilder:validation:Pattern="^[a-zA-Z0-9]{5,16}$"
// +kubebuilder:validation:Required
AppId string `json:"appId"`

// Buckets是存储桶, 是一个数组,可选存在
// +kubebuilder:validation:Optional
Buckets []string `json:"buckets,omitempty"`

// Websites是静态站点,是一个数组,可选存在
// +kubebuilder:validation:Optional
Websites []string `json:"websites,omitempty"`
}

// GatewayStatus defines the observed state of Gateway
type GatewayStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file

// AppDomain 是应用域名,必须存在
// +kubebuilder:validation:Required
AppDomain string `json:"appDomain"`

// BucketDomains 是存储桶域名列表,是一个数组,可选存在
// +kubebuilder:validation:Optional
BucketDomains []string `json:"bucketDomains,omitempty"`

// WebsiteDomains 是静态站点域名列表,是一个数组,可选存在
// +kubebuilder:validation:Optional
WebsiteDomains []string `json:"websiteDomains,omitempty"`
}

// BucketDomain 是存储桶位的域名配置
type BucketDomain struct {
// Name 是存储桶名称,必须存在
// +kubebuilder:validation:Required
Name string `json:"name"`

// Domain 是存储桶域名,必须存在
// +kubebuilder:validation:Required
Domain string `json:"domain"`
}

// WebsiteDomain 是静态站点的域名配置
type WebsiteDomain struct {
// Name 是静态站点名称,必须存在
// +kubebuilder:validation:Required
Name string `json:"name"`

// Domain 是静态站点域名,必须存在
// +kubebuilder:validation:Required
Domain string `json:"domain"`
}

//+kubebuilder:object:root=true
Expand Down
53 changes: 36 additions & 17 deletions controllers/gateway/api/v1/route_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,57 @@ type RouteSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// RouteType 是路由类型, 必须存在,且只能是下面的值之一 app、bucket、website
// +kubebuilder:validation:Enum=app;bucket;website
// Domain 是路由域名,必须存在
// +kubebuilder:validation:Required
RouteType string `json:"routeType"`

// AppId 是应用Id,必须存在,长度3到10之间,由字母和数字组合
// +kubebuilder:validation:MinLength=3
// +kubebuilder:validation:MaxLength=10
// +kubebuilder:validation:Pattern="^[a-zA-Z0-9]*$"
// +kubebuilder:validation:Required
AppId string `json:"appid"`

// Bucket是oss的bucket名称,可选存在
BucketName string `json:"bucketName,omitempty"`

// Domain 是自定义域名,非必须存在,需要匹配域名规则
// +kubebuilder:validation:Pattern="^[a-zA-Z0-9]*$"
Domain string `json:"domain,omitempty"`

// Backend是service配置, 必须存在
// +kubebuilder:validation:Required
Backend Backend `json:"backend"`

// CertConfigRef 是证书配置,可选存在
// +kubebuilder:validation:Optional
CertConfigRef string `json:"certConfigRef,omitempty"`

// 下面是一些规则配置,可选存在

// PathRewrite 是路径重写,可选存在
// +kubebuilder:validation:Optional
PathRewrite string `json:"pathRewrite,omitempty"`

// PassHost 传给上游的host,可选存在, 如果不设置,则默认将客户端的 host 透传给上游
// +kubebuilder:validation:Optional
PassHost string `json:"passHost,omitempty"`

// EnableWebSocket 是否开启websocket, 默认否
// +kubebuilder:validation:Optional
EnableWebSocket bool `json:"enableWebSocket,omitempty"`
}

// PathRewrite 是路径重写
type PathRewrite struct {
// Regex 是正则表达式,必须存在
// +kubebuilder:validation:Required
Regex string `json:"regex"`

//Replacement 是替代内容,必须存在
// +kubebuilder:validation:Required
Replacement string `json:"replacement"`
}

// RouteStatus defines the observed state of Route
type RouteStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file

// FullDomain 是路由的完整域名,必须存在
// Domain 是路由的完整域名,必须存在
// +kubebuilder:validation:Required
Domain string `json:"Domain"`

// SupportSSL 是否支持ssl, 默认为false
// +kubebuilder:validation:Required
FullDomain string `json:"fullDomain"`
SupportSSL bool `json:"supportSSL"`
}

// Backend defines the desired state of Backend
Expand Down
73 changes: 73 additions & 0 deletions controllers/gateway/config/crd/bases/gateway.laf.dev_domains.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.0
creationTimestamp: null
name: domains.gateway.laf.dev
spec:
group: gateway.laf.dev
names:
kind: Domain
listKind: DomainList
plural: domains
singular: domain
scope: Namespaced
versions:
- name: v1
schema:
openAPIV3Schema:
description: Domain is the Schema for the domains API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: DomainSpec defines the desired state of Domain
properties:
certConfigRef:
description: CertConfigRef 是字符串类型,是configMap的引用
type: string
domain:
description: Domain 是域名,是字符串类型,规则匹配域名规则,必须存在
pattern: ^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$
type: string
preferred:
description: Preferred 是提供域名使用位置的推荐项,是字符串类型,长度大于1小于10,必须存在
maxLength: 10
minLength: 1
type: string
region:
description: Region 是域名设定的解析区域,是字符串类型,长度大于1小于10,可选存在
maxLength: 10
minLength: 1
type: string
required:
- certConfigRef
- domain
- preferred
type: object
status:
description: DomainStatus defines the observed state of Domain
properties:
certConfigRef:
description: CertConfigRef 是字符串类型,是configMap的引用
type: string
required:
- certConfigRef
type: object
type: object
served: true
storage: true
subresources:
status: {}
78 changes: 78 additions & 0 deletions controllers/gateway/config/crd/bases/gateway.laf.dev_gateways.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.0
creationTimestamp: null
name: gateways.gateway.laf.dev
spec:
group: gateway.laf.dev
names:
kind: Gateway
listKind: GatewayList
plural: gateways
singular: gateway
scope: Namespaced
versions:
- name: v1
schema:
openAPIV3Schema:
description: Gateway is the Schema for the gateways API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: GatewaySpec defines the desired state of Gateway
properties:
appId:
description: AppId是应用id,字母数字组成,长度5至16位,必须存在
pattern: ^[a-zA-Z0-9]{5,16}$
type: string
buckets:
description: Buckets是存储桶, 是一个数组,可选存在
items:
type: string
type: array
websites:
description: Websites是静态站点,是一个数组,可选存在
items:
type: string
type: array
required:
- appId
type: object
status:
description: GatewayStatus defines the observed state of Gateway
properties:
appDomain:
description: AppDomain 是应用域名,必须存在
type: string
bucketDomains:
description: BucketDomains 是存储桶域名列表,是一个数组,可选存在
items:
type: string
type: array
websiteDomains:
description: WebsiteDomains 是静态站点域名列表,是一个数组,可选存在
items:
type: string
type: array
required:
- appDomain
type: object
type: object
served: true
storage: true
subresources:
status: {}
88 changes: 88 additions & 0 deletions controllers/gateway/config/crd/bases/gateway.laf.dev_routes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.0
creationTimestamp: null
name: routes.gateway.laf.dev
spec:
group: gateway.laf.dev
names:
kind: Route
listKind: RouteList
plural: routes
singular: route
scope: Namespaced
versions:
- name: v1
schema:
openAPIV3Schema:
description: Route is the Schema for the routes API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: RouteSpec defines the desired state of Route
properties:
backend:
description: Backend是service配置, 必须存在
properties:
serviceName:
description: ServiceName 是service的名称,必须存在
type: string
servicePort:
description: ServicePort是service的端口,必须存在
format: int32
type: integer
required:
- serviceName
- servicePort
type: object
certConfigRef:
description: CertConfigRef 是证书配置,可选存在
type: string
domain:
description: Domain 是路由域名,必须存在
pattern: ^[a-zA-Z0-9]*$
type: string
enableWebSocket:
description: EnableWebSocket 是否开启websocket, 默认否
type: boolean
passHost:
description: PassHost 传给上游的host,可选存在, 如果不设置,则默认将客户端的 host 透传给上游
type: string
pathRewrite:
description: PathRewrite 是路径重写,可选存在
type: string
required:
- backend
type: object
status:
description: RouteStatus defines the observed state of Route
properties:
Domain:
description: Domain 是路由的完整域名,必须存在
type: string
supportSSL:
description: SupportSSL 是否支持ssl, 默认为false
type: boolean
required:
- Domain
- supportSSL
type: object
type: object
served: true
storage: true
subresources:
status: {}
Loading

0 comments on commit 6f2d672

Please sign in to comment.