facts

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package facts holds the system facts used for module selection.

Index

Constants

This section is empty.

Variables

View Source
var KernelRelease = func() (string, error) {
	out, err := exec.Command("uname", "-r").Output()
	if err != nil {
		return "", fmt.Errorf("query kernel release: %w", err)
	}
	return strings.TrimSpace(string(out)), nil
}

KernelRelease returns the running kernel release (`uname -r`). It is a package-level var so tests can stub the lookup.

Functions

func CheckKernelConstraint added in v0.9.0

func CheckKernelConstraint(expr string) error

CheckKernelConstraint validates one "<op> <version>" kernel constraint expression (the when.kernel grammar), with <op> one of < <= > >= == !=. Empty or malformed expressions are rejected loudly; callers treating an empty expression as "unset" must check for it first.

func CompareKernel added in v0.9.0

func CompareKernel(release, op, version string) (bool, error)

CompareKernel compares a running kernel release against one constraint ("<", "<=", ">", ">=", "==", "!=" and a dotted-numeric version). Version comparison is numeric per dotted segment (7.10 > 7.1), with missing segments treated as zero; a distro suffix on the release ("6.12.1-arch1-1") is ignored.

Types

type Facts

type Facts struct {
	Hostname string
	Username string
	OS       string
	// Kernel is the running kernel release (`uname -r`, e.g.
	// "6.12.1-arch1-1"); empty when detection failed.
	Kernel  string
	Distro  string
	GPU     string
	Backend string
}

Facts holds the system facts used for module selection.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL