disk

package
v0.0.0-...-63dd1cf Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Darwin

type Darwin struct {
	provider.FactsAware

	PartitionsFn func(all bool) ([]disk.PartitionStat, error)
	UsageFn      func(path string) (*disk.UsageStat, error)
	// contains filtered or unexported fields
}

Darwin implements the Disk interface for Darwin (macOS).

func NewDarwinProvider

func NewDarwinProvider(
	logger *slog.Logger,
) *Darwin

NewDarwinProvider factory to create a new Darwin instance.

func (*Darwin) GetLocalUsageStats

func (d *Darwin) GetLocalUsageStats() ([]Result, error)

GetLocalUsageStats retrieves disk space statistics for local disks only. It returns a slice of Result structs, each containing the total, used, and free space in bytes for the corresponding local disk. It gracefully skips partitions where a permission error occurs (e.g., for mounts that the user cannot access without root privileges), and continues processing the remaining partitions. If a non-permission-related error occurs, the function returns an error.

type Debian

type Debian struct {
	provider.FactsAware

	PartitionsFn func(all bool) ([]disk.PartitionStat, error)
	UsageFn      func(path string) (*disk.UsageStat, error)
	// contains filtered or unexported fields
}

Debian implements the Mem interface for Debian.

func NewDebianProvider

func NewDebianProvider(
	logger *slog.Logger,
) *Debian

NewDebianProvider factory to create a new Debian instance.

func (*Debian) GetLocalUsageStats

func (u *Debian) GetLocalUsageStats() ([]Result, error)

GetLocalUsageStats retrieves disk space statistics for local disks only. It returns a slice of Result structs, each containing the total, used, and free space in bytes for the corresponding local disk. It gracefully skips partitions where a permission error occurs (e.g., for mounts that the user cannot access without root privileges), and continues processing the remaining partitions. If a non-permission-related error occurs, the function returns an error.

type Linux

type Linux struct {
	provider.FactsAware
}

Linux implements the Disk interface for Linux.

func NewLinuxProvider

func NewLinuxProvider() *Linux

NewLinuxProvider factory to create a new Linux instance.

func (*Linux) GetLocalUsageStats

func (l *Linux) GetLocalUsageStats() ([]Result, error)

GetLocalUsageStats retrieves disk space statistics for local disks only. It returns a slice of Result structs, each containing the total, used, and free space in bytes for the corresponding local disk. An error is returned if somethng goes wrong.

type Provider

type Provider interface {
	// GetLocalUsageStats retrieves disk space statistics.
	GetLocalUsageStats() ([]Result, error)
}

Provider implements the methods to interact with various Disk components.

type Result

type Result struct {
	// Disk identifier, e.g., "/dev/sda1"
	Name string
	// Total disk space in bytes
	Total uint64
	// Used disk space in bytes
	Used uint64
	// Free disk space in bytes
	Free uint64
	// Changed indicates whether system state was modified.
	Changed bool `json:"changed"`
}

Result holds information about disk space usage.

Directories

Path Synopsis
Package mocks provides mock implementations for testing.
Package mocks provides mock implementations for testing.

Jump to

Keyboard shortcuts

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