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

Validate disk size against image size on disk create form #1773

Open
david-crespo opened this issue Oct 5, 2023 · 1 comment
Open

Validate disk size against image size on disk create form #1773

david-crespo opened this issue Oct 5, 2023 · 1 comment
Labels

Comments

@david-crespo
Copy link
Collaborator

On instance create, we validate the size of the boot disk against the size of the chosen image, and when you change the image, we update the size to be big enough for it if necessary.

// Imitate API logic: only require that the disk is big enough to fit the image
validate={(diskSizeGiB) => {
if (!image) return true
if (diskSizeGiB < image.size / GiB) {
const minSize = Math.ceil(image.size / GiB)
return `Must be as large as selected image (min. ${minSize} GiB)`
}
if (diskSizeGiB > MAX_DISK_SIZE_GiB) {
return `Can be at most ${MAX_DISK_SIZE_GiB} GiB`
}
}}

On the standalone disk create form, we don't do that, and we should.

<DiskSizeField name="size" control={form.control} />

@david-crespo
Copy link
Collaborator Author

This could be worth picking up @charliepark if you become an expert on this while working on #1823.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant