disk

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package disk inspects explicitly named Linux block devices for disk plans. It does not change devices or authorize disk operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	Device      string   `json:"device"`
	StableIDs   []string `json:"stableIDs,omitempty"`
	Size        uint64   `json:"size"`
	Type        string   `json:"type"`
	Serial      string   `json:"serial,omitempty"`
	WWN         string   `json:"wwn,omitempty"`
	Filesystem  string   `json:"filesystem,omitempty"`
	Mountpoints []string `json:"mountpoints,omitempty"`
	Partitions  int      `json:"partitions"`
	Inspectable bool     `json:"inspectable"`
	Reason      string   `json:"reason,omitempty"`
}

Device is one block device on a host, for choosing a disk to inspect. Only a device that Inspectable marks may be passed to Probe; Reason says why not.

func List

func List(ctx context.Context, r Runner) ([]Device, error)

List reports every block device on the host and the stable IDs that name each one. It changes nothing.

func ParseList

func ParseList(b []byte) ([]Device, error)

ParseList validates the output of listScript. A device without a stable ID, with no serial or WWN, or with partitions is listed but not inspectable.

type Observation

type Observation struct {
	Requested   string        `json:"requested"`
	Device      string        `json:"device"`
	MajorMinor  string        `json:"majorMinor"`
	Size        uint64        `json:"size"`
	Type        string        `json:"type"`
	Serial      string        `json:"serial,omitempty"`
	WWN         string        `json:"wwn,omitempty"`
	Filesystem  string        `json:"filesystem,omitempty"`
	UUID        string        `json:"uuid,omitempty"`
	Mountpoints []string      `json:"mountpoints,omitempty"`
	Children    []Observation `json:"children,omitempty"`
}

Observation describes one exact device at a point in time. Callers must compare a fresh observation to the approved plan before changing the host.

func Parse

func Parse(requested string, b []byte) (Observation, error)

Parse validates lsblk's JSON. Missing identity or incomplete data is an error: a future writer must never mistake an unknown device for a blank one.

func Probe

func Probe(ctx context.Context, r Runner, path string) (Observation, error)

Probe accepts only an explicit stable by-id path and requests JSON output. The shell argument is constrained by byID, which excludes shell syntax.

type Runner

type Runner interface {
	Run(context.Context, string) ([]byte, error)
}

Runner executes a script on the host being inspected.

Jump to

Keyboard shortcuts

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