chore: clean types and align

This commit is contained in:
Harivansh Rathi 2026-04-07 15:49:26 -04:00
parent 3a256dc6e2
commit caeb9dfaa7
3 changed files with 45 additions and 46 deletions

View file

@ -6,7 +6,7 @@ import (
"strings"
)
// MachineID uniquely identifies a single microVM on a host.
// MachineID uniquely identifies a single firecracler microVM
type MachineID string
// MachineSpec describes the minimum machine inputs required to boot a guest.
@ -21,6 +21,20 @@ type MachineSpec struct {
Vsock *VsockSpec
}
// DriveSpec describes an additional guest block device.
type DriveSpec struct {
ID string
Path string
ReadOnly bool
}
// VsockSpec describes a single host-guest vsock device.
type VsockSpec struct {
ID string
CID uint32
Path string
}
// Validate reports whether the machine specification is usable for boot.
func (s MachineSpec) Validate() error {
if strings.TrimSpace(string(s.ID)) == "" {
@ -54,13 +68,6 @@ func (s MachineSpec) Validate() error {
return nil
}
// DriveSpec describes an additional guest block device.
type DriveSpec struct {
ID string
Path string
ReadOnly bool
}
// Validate reports whether the drive specification is usable.
func (d DriveSpec) Validate() error {
if strings.TrimSpace(d.ID) == "" {
@ -72,20 +79,13 @@ func (d DriveSpec) Validate() error {
return nil
}
// VsockSpec describes a single host-guest vsock device.
type VsockSpec struct {
ID string
CID uint32
Path string
}
// Validate reports whether the vsock specification is usable.
func (v VsockSpec) Validate() error {
if strings.TrimSpace(v.ID) == "" {
return fmt.Errorf("vsock id is required")
}
if v.CID == 0 {
return fmt.Errorf("vsock cid must be non-zero")
return fmt.Errorf("vsock cid must be non zero")
}
if strings.TrimSpace(v.Path) == "" {
return fmt.Errorf("vsock path is required")