Skip to content

Commit a182969

Browse files
committed
Move validation to crd level
1 parent 7ec0f87 commit a182969

File tree

8 files changed

+27
-13
lines changed

8 files changed

+27
-13
lines changed

config/crd/bases/k8s.nginx.org_virtualserverroutes.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -879,8 +879,11 @@ spec:
879879
ConfigMap key.'
880880
type: string
881881
client-body-buffer-size:
882-
description: Sets the size of the buffer used for reading the
883-
client request body.
882+
description: |-
883+
ClientBodyBufferSize sets the size of the buffer used for reading the client request body. Must be specified as a number followed by:
884+
'k' for kilobytes or 'm' for megabytes.
885+
Examples: "10m" or "512k".
886+
pattern: ^[0-9]+[kmg]$
884887
type: string
885888
client-max-body-size:
886889
description: Sets the maximum allowed size of the client request

config/crd/bases/k8s.nginx.org_virtualservers.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,8 +1068,11 @@ spec:
10681068
ConfigMap key.'
10691069
type: string
10701070
client-body-buffer-size:
1071-
description: Sets the size of the buffer used for reading the
1072-
client request body.
1071+
description: |-
1072+
ClientBodyBufferSize sets the size of the buffer used for reading the client request body. Must be specified as a number followed by:
1073+
'k' for kilobytes or 'm' for megabytes.
1074+
Examples: "10m" or "512k".
1075+
pattern: ^[0-9]+[kmg]$
10731076
type: string
10741077
client-max-body-size:
10751078
description: Sets the maximum allowed size of the client request

deploy/crds.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,8 +1917,11 @@ spec:
19171917
ConfigMap key.'
19181918
type: string
19191919
client-body-buffer-size:
1920-
description: Sets the size of the buffer used for reading the
1921-
client request body.
1920+
description: |-
1921+
ClientBodyBufferSize sets the size of the buffer used for reading the client request body. Must be specified as a number followed by:
1922+
'k' for kilobytes or 'm' for megabytes.
1923+
Examples: "10m" or "512k".
1924+
pattern: ^[0-9]+[kmg]$
19221925
type: string
19231926
client-max-body-size:
19241927
description: Sets the maximum allowed size of the client request
@@ -3340,8 +3343,11 @@ spec:
33403343
ConfigMap key.'
33413344
type: string
33423345
client-body-buffer-size:
3343-
description: Sets the size of the buffer used for reading the
3344-
client request body.
3346+
description: |-
3347+
ClientBodyBufferSize sets the size of the buffer used for reading the client request body. Must be specified as a number followed by:
3348+
'k' for kilobytes or 'm' for megabytes.
3349+
Examples: "10m" or "512k".
3350+
pattern: ^[0-9]+[kmg]$
33453351
type: string
33463352
client-max-body-size:
33473353
description: Sets the maximum allowed size of the client request

docs/crd/k8s.nginx.org_virtualserverroutes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ The `.spec` object supports the following fields:
169169
| `upstreams[].buffers.number` | `integer` | Configures the number of buffers. The default is set in the proxy-buffers ConfigMap key. |
170170
| `upstreams[].buffers.size` | `string` | Configures the size of a buffer. The default is set in the proxy-buffers ConfigMap key. |
171171
| `upstreams[].busy-buffers-size` | `string` | Sets the size of the buffers used for reading a response from the upstream server when the proxy_buffering is enabled. The default is set in the proxy-busy-buffers-size ConfigMap key.' |
172-
| `upstreams[].client-body-buffer-size` | `string` | Sets the size of the buffer used for reading the client request body. |
172+
| `upstreams[].client-body-buffer-size` | `string` | ClientBodyBufferSize sets the size of the buffer used for reading the client request body. Must be specified as a number followed by: 'k' for kilobytes or 'm' for megabytes. Examples: "10m" or "512k". |
173173
| `upstreams[].client-max-body-size` | `string` | Sets the maximum allowed size of the client request body. The default is set in the client-max-body-size ConfigMap key. |
174174
| `upstreams[].connect-timeout` | `string` | The timeout for establishing a connection with an upstream server. The default is specified in the proxy-connect-timeout ConfigMap key. |
175175
| `upstreams[].fail-timeout` | `string` | The time during which the specified number of unsuccessful attempts to communicate with an upstream server should happen to consider the server unavailable. The default is set in the fail-timeout ConfigMap key. |

docs/crd/k8s.nginx.org_virtualservers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ The `.spec` object supports the following fields:
204204
| `upstreams[].buffers.number` | `integer` | Configures the number of buffers. The default is set in the proxy-buffers ConfigMap key. |
205205
| `upstreams[].buffers.size` | `string` | Configures the size of a buffer. The default is set in the proxy-buffers ConfigMap key. |
206206
| `upstreams[].busy-buffers-size` | `string` | Sets the size of the buffers used for reading a response from the upstream server when the proxy_buffering is enabled. The default is set in the proxy-busy-buffers-size ConfigMap key.' |
207-
| `upstreams[].client-body-buffer-size` | `string` | Sets the size of the buffer used for reading the client request body. |
207+
| `upstreams[].client-body-buffer-size` | `string` | ClientBodyBufferSize sets the size of the buffer used for reading the client request body. Must be specified as a number followed by: 'k' for kilobytes or 'm' for megabytes. Examples: "10m" or "512k". |
208208
| `upstreams[].client-max-body-size` | `string` | Sets the maximum allowed size of the client request body. The default is set in the client-max-body-size ConfigMap key. |
209209
| `upstreams[].connect-timeout` | `string` | The timeout for establishing a connection with an upstream server. The default is specified in the proxy-connect-timeout ConfigMap key. |
210210
| `upstreams[].fail-timeout` | `string` | The time during which the specified number of unsuccessful attempts to communicate with an upstream server should happen to consider the server unavailable. The default is set in the fail-timeout ConfigMap key. |

internal/configs/version2/__snapshots__/templates_test.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3102,7 +3102,6 @@ server {
31023102
proxy_read_timeout 31s;
31033103
proxy_send_timeout 32s;
31043104
client_max_body_size 1m;
3105-
client_body_buffer_size 8k;
31063105
proxy_max_temp_file_size 1024m;
31073106

31083107
proxy_buffering on;

internal/configs/version2/templates_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1609,7 +1609,6 @@ var (
16091609
ProxyReadTimeout: "31s",
16101610
ProxySendTimeout: "32s",
16111611
ClientMaxBodySize: "1m",
1612-
ClientBodyBufferSize: "8k",
16131612
ProxyBuffering: true,
16141613
ProxyBuffers: "8 4k",
16151614
ProxyBufferSize: "4k",

pkg/apis/configuration/v1/types.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@ type Upstream struct {
157157
ProxyBusyBuffersSize string `json:"busy-buffers-size"`
158158
// Sets the maximum allowed size of the client request body. The default is set in the client-max-body-size ConfigMap key.
159159
ClientMaxBodySize string `json:"client-max-body-size"`
160-
// Sets the size of the buffer used for reading the client request body.
160+
// +kubebuilder:validation:Optional
161+
// +kubebuilder:validation:Pattern=`^[0-9]+[kmg]$`
162+
// ClientBodyBufferSize sets the size of the buffer used for reading the client request body. Must be specified as a number followed by:
163+
// 'k' for kilobytes or 'm' for megabytes.
164+
// Examples: "10m" or "512k".
161165
ClientBodyBufferSize string `json:"client-body-buffer-size"`
162166
// The TLS configuration for the Upstream.
163167
TLS UpstreamTLS `json:"tls"`

0 commit comments

Comments
 (0)