A convenient CLI tool to quickly spin up DragonflyBSD virtual machines using QEMU with sensible defaults.
at main 1.2 kB view raw
1import z from "@zod/zod"; 2 3export type STATUS = "RUNNING" | "STOPPED"; 4 5export const MachineParamsSchema = z.object({ 6 portForward: z.array(z.string().regex(/^\d+:\d+$/)).optional(), 7 cpu: z.string().optional(), 8 cpus: z.number().min(1).optional(), 9 memory: z.string().regex(/^\d+(M|G)$/).optional(), 10}); 11 12export type MachineParams = z.infer<typeof MachineParamsSchema>; 13 14export const NewMachineSchema = MachineParamsSchema.extend({ 15 portForward: z.array(z.string().regex(/^\d+:\d+$/)).optional(), 16 cpu: z.string().default("host").optional(), 17 cpus: z.number().min(1).default(8).optional(), 18 memory: z.string().regex(/^\d+(M|G)$/).default("2G").optional(), 19 image: z.string().regex( 20 /^([a-zA-Z0-9\-\.]+\/)?([a-zA-Z0-9\-\.]+\/)?[a-zA-Z0-9\-\.]+(:[\w\.\-]+)?$/, 21 ), 22 volume: z.string().optional(), 23 bridge: z.string().optional(), 24}); 25 26export type NewMachine = z.infer<typeof NewMachineSchema>; 27 28export const NewVolumeSchema = z.object({ 29 name: z.string(), 30 baseImage: z.string().regex( 31 /^([a-zA-Z0-9\-\.]+\/)?([a-zA-Z0-9\-\.]+\/)?[a-zA-Z0-9\-\.]+(:[\w\.\-]+)?$/, 32 ), 33 size: z.string().regex(/^\d+(M|G|T)$/).optional(), 34}); 35 36export type NewVolume = z.infer<typeof NewVolumeSchema>;