Skip to content

Commit

Permalink
allow more characters in cluster name (#4316)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feroze Mohideen authored Feb 22, 2024
1 parent 80ce160 commit 2bf0da2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
31 changes: 10 additions & 21 deletions dashboard/src/lib/clusters/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,15 +400,16 @@ const cidrRangeValidator = z
}
);

const clusterNameValidator = z
.string()
.min(1, { message: "Name must be at least 1 character" })
.max(38, { message: "Name must be max 38 characters" })
.regex(/^[a-z0-9-]{1,61}$/, {
message: 'Lowercase letters, numbers, and "-" only.',
});
const eksConfigValidator = z.object({
kind: z.literal("EKS"),
clusterName: z
.string()
.min(1, { message: "Name must be at least 1 character" })
.max(31, { message: "Name must be max 31 characters" })
.regex(/^[a-z0-9-]{1,61}$/, {
message: 'Lowercase letters, numbers, and "-" only.',
}),
clusterName: clusterNameValidator,
clusterVersion: z.string().optional().default(""),
region: awsRegionValidator,
nodeGroups: eksNodeGroupValidator.array(),
Expand Down Expand Up @@ -462,27 +463,15 @@ const eksConfigValidator = z.object({
});
const gkeConfigValidator = z.object({
kind: z.literal("GKE"),
clusterName: z
.string()
.min(1, { message: "Name must be at least 1 character" })
.max(31, { message: "Name must be max 31 characters" })
.regex(/^[a-z0-9-]{1,61}$/, {
message: 'Lowercase letters, numbers, and "-" only.',
}),
clusterName: clusterNameValidator,
clusterVersion: z.string().optional().default(""),
region: gcpRegionValidator,
nodeGroups: gkeNodeGroupValidator.array(),
cidrRange: cidrRangeValidator,
});
const aksConfigValidator = z.object({
kind: z.literal("AKS"),
clusterName: z
.string()
.min(1, { message: "Name must be at least 1 character" })
.max(31, { message: "Name must be max 31 characters" })
.regex(/^[a-z0-9-]{1,61}$/, {
message: 'Lowercase letters, numbers, and "-" only.',
}),
clusterName: clusterNameValidator,
clusterVersion: z.string().optional().default(""),
region: azureRegionValidator,
nodeGroups: aksNodeGroupValidator.array(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const ClusterFormContextProvider: React.FC<ClusterFormContextProviderProps> = ({
);
}
if (Object.keys(errors).length > 0) {
// TODO: remove this and properly handle form validation errors
console.log("errors", errors);
}
if (isHandlingPreflightChecks) {
Expand Down

0 comments on commit 2bf0da2

Please sign in to comment.