Skip to content

Commit

Permalink
update and fix more nodebalancer schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
bnussman committed Dec 5, 2024
1 parent 436fa92 commit 32cfa65
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions packages/validation/src/nodebalancers.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ export const createNodeBalancerConfigSchema = object({
});

export const UpdateNodeBalancerConfigSchema = object({
algorithm: mixed().oneOf(['roundrobin', 'leastconn', 'source']),
algorithm: string().when('protocol', {
is: 'udp',
then: (schema) => schema.oneOf(['roundrobin', 'leastconn', 'ring_hash']),
otherwise: (schema) => schema.oneOf(['roundrobin', 'leastconn', 'source']),
}),
check_attempts: number()
.min(
CHECK_ATTEMPTS.MIN,
Expand Down Expand Up @@ -194,7 +198,7 @@ export const UpdateNodeBalancerConfigSchema = object({
.integer()
.min(1, PORT_WARNING)
.max(65535, PORT_WARNING),
protocol: mixed().oneOf(['http', 'https', 'tcp']),
protocol: string().oneOf(['http', 'https', 'tcp', 'udp']),
ssl_key: string().when('protocol', {
is: 'https',
then: (schema) => schema.required(),
Expand All @@ -203,8 +207,12 @@ export const UpdateNodeBalancerConfigSchema = object({
is: 'https',
then: (schema) => schema.required(),
}),
stickiness: mixed().oneOf(['none', 'table', 'http_cookie']),
nodes: array().of(nodeBalancerConfigNodeSchema),
udp_check_port: number().min(1).max(65535),
stickiness: string().when('protocol', {
is: 'udp',
then: (schema) => schema.oneOf(['none', 'source_ip', 'session']),
otherwise: (schema) => schema.oneOf(['none', 'table', 'http_cookie']),
}),
});

const client_conn_throttle = number()
Expand Down Expand Up @@ -243,6 +251,8 @@ export const NodeBalancerSchema = object({

client_udp_sess_throttle,

tags: array(string()),

region: string().required('Region is required.'),

configs: array()
Expand Down Expand Up @@ -287,10 +297,7 @@ export const UpdateNodeBalancerSchema = object({
/^[a-zA-Z0-9-_]+$/,
"Label can't contain special characters or spaces."
),

client_conn_throttle,

client_udp_sess_throttle,

region: string(),
tags: array(string()),
});

0 comments on commit 32cfa65

Please sign in to comment.