Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upcoming: [M3-9511] - VPC IPv6 - Update endpoints and types for VPC Entity #11852

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Upcoming Features
---

Added optional ipv6 property to VPC entity ([#11852](https://github.com/linode/manager/pull/11852))
10 changes: 10 additions & 0 deletions packages/api-v4/src/vpcs/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
interface VPCIPv6 {
range?: string;
}

interface CreateVPCIPV6 extends VPCIPv6 {
allocation_class?: string;
}

export interface VPC {
id: number;
label: string;
Expand All @@ -6,12 +14,14 @@ export interface VPC {
subnets: Subnet[];
created: string;
updated: string;
ipv6?: VPCIPv6[];
}

export interface CreateVPCPayload {
label: string;
description?: string;
region: string;
ipv6?: CreateVPCIPV6[];
subnets?: CreateSubnetPayload[];
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/validation": Upcoming Features
---

Added optional ipv6 to `createVPCIPv6Schema` ([#11852](https://github.com/linode/manager/pull/11852))
24 changes: 24 additions & 0 deletions packages/validation/src/vpcs.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const vpcsValidateIP = ({
}

if (isIPv6) {
// VPCs must be assigned an IPv6 prefix of /52, /48, or /44
if (!['52', '48', '44'].includes(mask)) {
return false;
}
if (shouldHaveIPMask) {
ipaddr.IPv6.parseCIDR(value);
} else {
Expand Down Expand Up @@ -210,11 +214,31 @@ export const createSubnetSchema = object().shape(
]
);

const createVPCIPv6Schema = object({
range: string()
.optional()
.test({
name: 'IPv6 prefix length',
message: 'Must be the prefix length 52, 48, or 44 of the IP, e.g. /52',
test: (value) => {
if (value && value !== 'auto' && value.length > 0) {
vpcsValidateIP({
value,
shouldHaveIPMask: true,
mustBeIPMask: false,
});
}
},
}),
allocation_class: string().optional(),
});

export const createVPCSchema = object({
label: labelValidation.required(LABEL_REQUIRED),
description: string(),
region: string().required('Region is required'),
subnets: array().of(createSubnetSchema),
ipv6: array().of(createVPCIPv6Schema).max(1).optional(),
});

export const modifySubnetSchema = object({
Expand Down