From 8d8b76b1e77b57c07a6028480ee54102f8a08e32 Mon Sep 17 00:00:00 2001 From: huabing zhao Date: Mon, 22 Apr 2024 10:26:01 -0700 Subject: [PATCH] fix test Signed-off-by: huabing zhao --- api/v1alpha1/clienttrafficpolicy_types.go | 11 +++++++--- api/v1alpha1/connection_types.go | 4 +++- api/v1alpha1/shared_types.go | 22 ------------------- ...y.envoyproxy.io_clienttrafficpolicies.yaml | 8 +++---- site/content/en/latest/api/extension_types.md | 18 +++------------ 5 files changed, 18 insertions(+), 45 deletions(-) diff --git a/api/v1alpha1/clienttrafficpolicy_types.go b/api/v1alpha1/clienttrafficpolicy_types.go index 1a8e5bb2b70..c920274008b 100644 --- a/api/v1alpha1/clienttrafficpolicy_types.go +++ b/api/v1alpha1/clienttrafficpolicy_types.go @@ -6,6 +6,7 @@ package v1alpha1 import ( + "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" ) @@ -207,13 +208,17 @@ type HTTP10Settings struct { type HTTP2Settings struct { // InitialStreamWindowSize sets the initial window size for HTTP/2 streams. // If not set, the default value is 64 KiB(64*1024). + // + // +kubebuilder:validation:XValidation:rule="type(self) == string ? self.matches(r\"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$\") : type(self) == int",message="initialStreamWindowSize must be of the format \"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$\"" // +optional - InitialStreamWindowSize *Size `json:"initialStreamWindowSize,omitempty"` + InitialStreamWindowSize *resource.Quantity `json:"initialStreamWindowSize,omitempty"` // InitialConnectionWindowSize sets the initial window size for HTTP/2 connections. - // If not set, the default value is 1 MiB(1024*1024). + // If not set, the default value is 1 MiB. + // + // +kubebuilder:validation:XValidation:rule="type(self) == string ? self.matches(r\"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$\") : type(self) == int",message="initialConnectionWindowSize must be of the format \"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$\"" // +optional - InitialConnectionWindowSize *Size `json:"initialConnectionWindowSize,omitempty"` + InitialConnectionWindowSize *resource.Quantity `json:"initialConnectionWindowSize,omitempty"` // MaxConcurrentStreams sets the maximum number of concurrent streams allowed per connection. // If not set, the default value is 100. diff --git a/api/v1alpha1/connection_types.go b/api/v1alpha1/connection_types.go index e099d5517c6..999cfcc4144 100644 --- a/api/v1alpha1/connection_types.go +++ b/api/v1alpha1/connection_types.go @@ -6,6 +6,7 @@ package v1alpha1 import ( + "k8s.io/apimachinery/pkg/api/resource" gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" ) @@ -20,8 +21,9 @@ type Connection struct { // Note that when the suffix is not provided, the value is interpreted as bytes. // Default: 32768 bytes. // + // +kubebuilder:validation:XValidation:rule="type(self) == string ? self.matches(r\"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$\") : type(self) == int",message="bufferLimit must be of the format \"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$\"" // +optional - BufferLimit *Size `json:"bufferLimit,omitempty"` + BufferLimit *resource.Quantity `json:"bufferLimit,omitempty"` } type ConnectionLimit struct { diff --git a/api/v1alpha1/shared_types.go b/api/v1alpha1/shared_types.go index c9fff3c1557..e07c8ec158e 100644 --- a/api/v1alpha1/shared_types.go +++ b/api/v1alpha1/shared_types.go @@ -10,7 +10,6 @@ import ( autoscalingv2 "k8s.io/api/autoscaling/v2" corev1 "k8s.io/api/core/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - "k8s.io/apimachinery/pkg/api/resource" gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" ) @@ -447,24 +446,3 @@ type BackendRef struct { // Only service Kind is supported for now. gwapiv1.BackendObjectReference `json:",inline"` } - -// Size is a wrapper around resource.Quantity to provide a more descriptive name and validation. -// +kubebuilder:validation:XValidation:rule="type(self) == string ? self.matches(r\"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$\") : type(self) == int",message="size must be of the format \"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$\"" -// +k8s:deepcopy-gen=false -type Size resource.Quantity - -// DeepCopy returns a deep copy of the Size. -func (s Size) DeepCopy() Size { - q := resource.Quantity(s) - return Size(q.DeepCopy()) -} - -// AsInt64 returns a representation of the current value as an int64. -func (s Size) AsInt64() (int64, bool) { - return (*resource.Quantity)(&s).AsInt64() -} - -// String formats the Quantity as a string, caching the result if not calculated. -func (s Size) String() string { - return (*resource.Quantity)(&s).String() -} diff --git a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_clienttrafficpolicies.yaml b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_clienttrafficpolicies.yaml index 39c56e864a3..b8dacf05eea 100644 --- a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_clienttrafficpolicies.yaml +++ b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_clienttrafficpolicies.yaml @@ -109,7 +109,7 @@ spec: pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true x-kubernetes-validations: - - message: size must be of the format "^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$" + - message: bufferLimit must be of the format "^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$" rule: 'type(self) == string ? self.matches(r"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$") : type(self) == int' connectionLimit: @@ -192,11 +192,11 @@ spec: - type: string description: |- InitialConnectionWindowSize sets the initial window size for HTTP/2 connections. - If not set, the default value is 1 MiB(1024*1024). + If not set, the default value is 1 MiB. pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true x-kubernetes-validations: - - message: size must be of the format "^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$" + - message: initialConnectionWindowSize must be of the format "^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$" rule: 'type(self) == string ? self.matches(r"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$") : type(self) == int' initialStreamWindowSize: @@ -209,7 +209,7 @@ spec: pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true x-kubernetes-validations: - - message: size must be of the format "^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$" + - message: initialStreamWindowSize must be of the format "^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$" rule: 'type(self) == string ? self.matches(r"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$") : type(self) == int' maxConcurrentStreams: diff --git a/site/content/en/latest/api/extension_types.md b/site/content/en/latest/api/extension_types.md index e6d6cef725d..e5e5d9fd11b 100644 --- a/site/content/en/latest/api/extension_types.md +++ b/site/content/en/latest/api/extension_types.md @@ -489,7 +489,7 @@ _Appears in:_ | Field | Type | Required | Description | | --- | --- | --- | --- | | `connectionLimit` | _[ConnectionLimit](#connectionlimit)_ | false | ConnectionLimit defines limits related to connections | -| `bufferLimit` | _[Size](#size)_ | false | BufferLimit provides configuration for the maximum buffer size in bytes for each incoming connection.
For example, 20Mi, 1Gi, 256Ki etc.
Note that when the suffix is not provided, the value is interpreted as bytes.
Default: 32768 bytes. | +| `bufferLimit` | _[Quantity](#quantity)_ | false | BufferLimit provides configuration for the maximum buffer size in bytes for each incoming connection.
For example, 20Mi, 1Gi, 256Ki etc.
Note that when the suffix is not provided, the value is interpreted as bytes.
Default: 32768 bytes. | #### ConnectionLimit @@ -1495,8 +1495,8 @@ _Appears in:_ | Field | Type | Required | Description | | --- | --- | --- | --- | -| `initialStreamWindowSize` | _[Size](#size)_ | false | InitialStreamWindowSize sets the initial window size for HTTP/2 streams.
If not set, the default value is 64 KiB(64*1024). | -| `initialConnectionWindowSize` | _[Size](#size)_ | false | InitialConnectionWindowSize sets the initial window size for HTTP/2 connections.
If not set, the default value is 1 MiB(1024*1024). | +| `initialStreamWindowSize` | _[Quantity](#quantity)_ | false | InitialStreamWindowSize sets the initial window size for HTTP/2 streams.
If not set, the default value is 64 KiB(64*1024). | +| `initialConnectionWindowSize` | _[Quantity](#quantity)_ | false | InitialConnectionWindowSize sets the initial window size for HTTP/2 connections.
If not set, the default value is 1 MiB. | | `maxConcurrentStreams` | _integer_ | true | MaxConcurrentStreams sets the maximum number of concurrent streams allowed per connection.
If not set, the default value is 100. | @@ -2943,18 +2943,6 @@ _Appears in:_ | `minDrainDuration` | _[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#duration-v1-meta)_ | false | MinDrainDuration defines the minimum drain duration allowing time for endpoint deprogramming to complete.
If unspecified, defaults to 5 seconds. | -#### Size - -_Underlying type:_ _Quantity_ - -Size is a wrapper around resource.Quantity to provide a more descriptive name and validation. - -_Appears in:_ -- [Connection](#connection) -- [HTTP2Settings](#http2settings) - - - #### SlowStart