Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
Merge pull request #358 from threefoldtech/development_fix_vm_disk_va…
Browse files Browse the repository at this point in the history
…lidation

fix vm disk validation
  • Loading branch information
abom authored Dec 23, 2021
2 parents 67d32bb + 036766f commit 9200382
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/types/vm.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { v4 } from "uuid";
import type { IFormField } from ".";
import isValidInteger from "../utils/isValidInteger";
import { validateDisk } from "../utils/validateName";
import { Network } from "./kubernetes";
import NodeID from "./nodeId";

export class Env {
constructor(public id = v4(), public key = "", public value = "") {}
constructor(public id = v4(), public key = "", public value = "") { }

public get valid(): boolean {
const { key, value } = this;
Expand All @@ -17,19 +18,21 @@ export class Disk {
// prettier-ignore
public diskFields: IFormField[] = [
{ label: "Name", symbol: "name", placeholder: "Disk Name", type: "text" },
{ label: "Size", symbol: "size", placeholder: "Disk size in GB", type: "number" },
{ label: "Mount Point", symbol: "mountpoint", placeholder: "Disk Mount Point", type: "text", validator(point: string): string | void {
point = point.trim();
if (point === "" || point === "/" || !point.startsWith("/")) return "Mount Point must start '/' and can't be positioned at root('/')"
}, invalid: false },
{ label: "Size", symbol: "size", placeholder: "Disk size in GB", type: "number", validator: validateDisk },
{
label: "Mount Point", symbol: "mountpoint", placeholder: "Disk Mount Point", type: "text", validator(point: string): string | void {
point = point.trim();
if (point === "" || point === "/" || !point.startsWith("/")) return "Mount Point must start '/' and can't be positioned at root('/')"
}, invalid: false
},
]

constructor(
public id = v4(),
public name = "DISK" + id.split("-")[0],
public size = 50,
public mountpoint = "/opt/"
) {}
) { }

public get valid(): boolean {
const { name, size, mountpoint } = this;
Expand Down Expand Up @@ -66,7 +69,7 @@ export default class VM {
public publicIp = false,

public selection = new NodeID()
) {}
) { }

public get valid(): boolean {
const { name, flist, cpu, memory, entrypoint, nodeId } = this;
Expand Down

0 comments on commit 9200382

Please sign in to comment.