Skip to content

Commit

Permalink
fix(disk) preserve devices.root.size.state key on instance configurat…
Browse files Browse the repository at this point in the history
…ion update (#823)

## Done

- preserve devices.root.size.state key on instance configuration update

Fixes WD-13755
  • Loading branch information
edlerd authored Jul 30, 2024
2 parents 4d1421d + aea24ad commit ae29e8e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/types/device.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export interface LxdDiskDevice {
path?: string;
pool: string;
size?: string;
"size.state"?: string;
source?: string;
"limits.read"?: string;
"limits.write"?: string;
Expand Down
2 changes: 2 additions & 0 deletions src/util/formDevices.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const deviceYaml =
" root:\n" +
" path: /\n" +
" pool: big-pool\n" +
" size: 10GiB\n" +
" type: disk\n" +
" size.state: 3GiB\n" +
" eth0:\n" +
" network: lxcbr\n" +
" type: nic\n" +
Expand Down
6 changes: 6 additions & 0 deletions src/util/formDevices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export type FormDiskDevice = Partial<LxdDiskDevice> &
read?: string;
write?: string;
};
size_state?: string;
};

export type FormNetworkDevice = Partial<LxdNicDevice> &
Expand Down Expand Up @@ -87,6 +88,10 @@ export const formDeviceToPayload = (devices: FormDevice[]) => {
}
delete item.limits;
}
if ("size_state" in item) {
item["size.state"] = item.size_state;
delete item.size_state;
}
if ("size" in item && !item.size?.match(/^\d/)) {
delete item.size;
}
Expand Down Expand Up @@ -137,6 +142,7 @@ export const parseDevices = (devices: LxdDevices): FormDevice[] => {
pool: item.pool,
source: "source" in item ? item.source : undefined,
size: "size" in item ? item.size : undefined,
size_state: "size.state" in item ? item["size.state"] : undefined,
limits: {
read: "limits.read" in item ? item["limits.read"] : undefined,
write: "limits.write" in item ? item["limits.write"] : undefined,
Expand Down

0 comments on commit ae29e8e

Please sign in to comment.