Documentation
¶
Overview ¶
Package system provides host system detection for StackKits.
Index ¶
- func AddToLVM(ctx context.Context, devicePath, vgName string) error
- func CanRunContainers(ctx context.Context, binary string) bool
- func DetectBlockDevices(ctx context.Context) ([]models.BlockDevice, error)
- func DetectCPUCores() int
- func DetectMemoryGB() float64
- func FilterAvailableDevices(devices []models.BlockDevice, rootDevice string) []models.BlockDevice
- func FormatAndMount(ctx context.Context, devicePath, mountPoint string) error
- func IsContainerBlocked(virt VirtType) bool
- func ParseLsblkOutput(data []byte) ([]models.BlockDevice, error)
- type Runtime
- type VirtType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddToLVM ¶
AddToLVM adds a device as a physical volume to the given volume group, then extends the root logical volume and resizes the filesystem.
func CanRunContainers ¶
CanRunContainers tests whether a container runtime can actually create containers. This catches OpenVZ/LXC hosts where the daemon starts but containers fail.
func DetectBlockDevices ¶
func DetectBlockDevices(ctx context.Context) ([]models.BlockDevice, error)
DetectBlockDevices discovers block devices on the host using lsblk.
func DetectCPUCores ¶
func DetectCPUCores() int
DetectCPUCores returns the number of CPU cores on the host.
func DetectMemoryGB ¶
func DetectMemoryGB() float64
DetectMemoryGB returns the total system memory in GB.
func FilterAvailableDevices ¶
func FilterAvailableDevices(devices []models.BlockDevice, rootDevice string) []models.BlockDevice
FilterAvailableDevices returns devices that are unmounted, have no filesystem, are not the root disk, and are at least 1 GB.
func FormatAndMount ¶
FormatAndMount formats a device with ext4, mounts it, and adds an fstab entry.
func IsContainerBlocked ¶
IsContainerBlocked returns true if the virt type is known to block container creation.
func ParseLsblkOutput ¶
func ParseLsblkOutput(data []byte) ([]models.BlockDevice, error)
ParseLsblkOutput parses the JSON output of lsblk into BlockDevice models.
Types ¶
type VirtType ¶
type VirtType string
VirtType represents the virtualization technology of the host.
const ( VirtNone VirtType = "none" // bare metal VirtKVM VirtType = "kvm" VirtVMware VirtType = "vmware" VirtHyperV VirtType = "microsoft" VirtXen VirtType = "xen" VirtOpenVZ VirtType = "openvz" VirtLXC VirtType = "lxc" VirtDocker VirtType = "docker" VirtWSL VirtType = "wsl" VirtUnknown VirtType = "unknown" )
func DetectVirt ¶
DetectVirt returns the virtualization type of the current host. Uses systemd-detect-virt when available, falls back to /proc checks.