plugins

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: Apache-2.0 Imports: 68 Imported by: 5

Documentation

Index

Constants

View Source
const (
	OneMiBInBytes = 1024 * 1024
	Ext4          = "ext4"
	Ext3          = "ext3"
	Ext2          = "ext2"
	Fat           = "fat"
	Vfat          = "vfat"
	Fat32         = "fat32"
	Fat16         = "fat16"
	Xfs           = "xfs"
	Btrfs         = "btrfs"
	Swap          = "swap"
)
View Source
const (
	// BLKGETSIZE64 returns u64 device size in bytes when called on a block device fd.
	BLKGETSIZE64 = 0x80081272
	// EXT4_IOC_RESIZE_FS precomputed value for 64-bit Linux (x86_64, arm64, riscv64, ppc64le)
	// Otherwise make a IOW('f', 16, __u64) -> 0x40086610
	// https://github.com/torvalds/linux/blob/master/include/uapi/linux/ext4.h#L26
	EXT4_IOC_RESIZE_FS = 0x40086610

	// XFS_IOC_FSGROWFSDATA = _IOW('X', 110, struct xfs_growfs_data) -> size=16 -> 0x4010586e
	// https://github.com/torvalds/linux/blob/master/fs/xfs/libxfs/xfs_fs.h#L1059
	XFS_IOC_FSGROWFSDATA = 0x4010586e

	// BTRFS_IOC_RESIZE = _IOW(0x94, 3, struct btrfs_ioctl_vol_args) -> size=4096 -> 0x50009403
	// https://github.com/torvalds/linux/blob/master/include/uapi/linux/btrfs.h#L1106
	BTRFS_IOC_RESIZE = 0x50009403
)
View Source
const (
	ErrorEmptyOverrideService = "Skipping empty override service"
	ErrorEmptyOverrideContent = "Empty override content for %s"
	DefaultOverrideName       = "override-yip.conf"
	DefaultOverrideDir        = "/etc/systemd/system/%s.d"
	DefaultServiceExt         = ".service"
	DefaultOverrideExt        = ".conf"
	EmptyString               = ""
)
View Source
const RunOnlyOs = "running stage (OnlyIfOs regex (%s)"
View Source
const RunOnlyOsVersion = "running stage (OnlyIfOsVersion regex (%s)"
View Source
const SkipBothServices = "both systemd and openrc are available, cant filter"
View Source
const SkipNotSupportedServiceManager = "service manager %s is not supported"
View Source
const SkipOnlyArch = "arch %s doesn't match %s"
View Source
const SkipOnlyOs = "OnlyIfOs regex (%s)"
View Source
const SkipOnlyOsVersion = "OnlyIfOsVersion regex (%s)"
View Source
const SkipOnlyServiceManager = "service manager doesn't match %s"

Variables

This section is empty.

Functions

func Build added in v1.9.4

func Build(path string, nameservers, dnsSearch, dnsOptions []string) error

func Commands

func Commands(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func DNS

func DNS(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func DataSources

func DataSources(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func DecodeMultipartVmware added in v1.3.1

func DecodeMultipartVmware(data []byte) []byte

DecodeMultipartVmware will try to decode the user-data from VMWARE provider as it returns a multipart/mixed data instead of the simple cloud-config

func DeleteEntities

func DeleteEntities(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func Download

func Download(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func EnsureDirectories

func EnsureDirectories(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func EnsureFiles

func EnsureFiles(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func Entities

func Entities(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func Environment

func Environment(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func Git

func Git(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func Hostname

func Hostname(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func IfArch added in v1.14.1

func IfArch(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

IfArch checks if the current architecture matches the one specified in the stage Only runs if the regex matches the current architecture

func IfConditional

func IfConditional(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func IfFiles added in v1.18.0

func IfFiles(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func IfServiceManager added in v1.14.1

func IfServiceManager(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

IfServiceManager checks if the current service manager matches the one specified in the stage Only runs if the service manager matches the specified service manager

func Layout

func Layout(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func LoadModules

func LoadModules(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func MiBToSectors

func MiBToSectors(size uint64, sectorSize uint64) uint64

func NodeConditional

func NodeConditional(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func OnlyIfOS added in v1.14.0

func OnlyIfOS(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

OnlyIfOS checks if the OS matches the if statement and runs it if so

func OnlyIfOSVersion added in v1.14.0

func OnlyIfOSVersion(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

OnlyIfOSVersion checks if the OS VERSION matches the if statement and runs it if so

func Packages added in v1.13.0

func Packages(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

Packages runs the package manager to try to install/remove/upgrade/refresh packages It will try to identify the package manager based on the distro If it can't identify the package manager, it will return an error Order is Refresh -> Upgrade -> Install -> Remove

func SSH

func SSH(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func Sysctl

func Sysctl(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func SystemHostname

func SystemHostname(hostname string, fs vfs.FS) error

func Systemctl

func Systemctl(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func SystemdFirstboot

func SystemdFirstboot(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func Timesyncd

func Timesyncd(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func UnpackImage added in v1.14.0

func UnpackImage(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

func UpdateHostsFile

func UpdateHostsFile(hostname string, fs vfs.FS) error

func User

func User(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error

Types

type Console

type Console interface {
	Run(string, ...func(*exec.Cmd)) (string, error)
	Start(*exec.Cmd, ...func(*exec.Cmd)) error
	RunTemplate([]string, string) error
}

type Disk

type Disk struct {
	Device  string
	SectorS uint64
	LastS   uint64
	Parts   []Partition
}

func FindDiskFromLabel added in v1.19.0

func FindDiskFromLabel(label string, fs vfs.FS) (Disk, error)

func FindDiskFromPath

func FindDiskFromPath(path string, fs vfs.FS) (Disk, error)

func (*Disk) AddPartitions added in v1.19.0

func (dev *Disk) AddPartitions(fs vfs.FS, parts []schema.Partition, l logger.Interface, console Console) error

func (*Disk) CheckDiskFreeSpaceMiB

func (dev *Disk) CheckDiskFreeSpaceMiB(minSpace uint64) bool

func (*Disk) ExpandLastPartition

func (dev *Disk) ExpandLastPartition(fs vfs.FS, size uint64, console Console) error

func (*Disk) MatchPartitionFSLabel added in v1.19.0

func (dev *Disk) MatchPartitionFSLabel(label string) bool

func (*Disk) MatchPartitionPLabel added in v1.19.0

func (dev *Disk) MatchPartitionPLabel(label string) bool

type Distro added in v1.13.0

type Distro string
const (
	Debian             Distro = "debian"
	Ubuntu             Distro = "ubuntu"
	RedHat             Distro = "rhel"
	CentOS             Distro = "centos"
	RockyLinux         Distro = "rocky"
	AlmaLinux          Distro = "almalinux"
	Fedora             Distro = "fedora"
	Arch               Distro = "arch"
	Alpine             Distro = "alpine"
	OpenSUSELeap       Distro = "opensuse-leap"
	OpenSUSETumbleweed Distro = "opensuse-tumbleweed"
	SUSE               Distro = "suse"
	OpenEuler          Distro = "openEuler"
)

type FilesystemDetector added in v1.19.0

type FilesystemDetector interface {
	DetectFileSystemType(part *gpt.Partition, d *disk.Disk) (string, error)
}

FilesystemDetector allows mocking filesystem detection in tests.

var DefaultFilesystemDetector FilesystemDetector = RealFilesystemDetector{}

type GrowFsToMaxInterface added in v1.19.0

type GrowFsToMaxInterface interface {
	GrowFSToMax(device string, filesystem string) error
}

GrowFsToMaxInterface defines an interface for growing filesystems to max size.

var DefaultGrowFsToMax GrowFsToMaxInterface = &RealGrowFsToMax{}

DefaultGrowFsToMax is the default instance of GrowFsToMaxInterface.

type Installer added in v1.13.0

type Installer string
const (
	APTInstaller     Installer = "apt-get"
	DNFInstaller     Installer = "dnf"
	PacmanInstaller  Installer = "pacman"
	SUSEInstaller    Installer = "zypper"
	AlpineInstaller  Installer = "apk"
	UnknownInstaller Installer = "unknown"
)

func (Installer) String added in v1.13.0

func (d Installer) String() string

type MkfsCall

type MkfsCall struct {
	// contains filtered or unexported fields
}

func (MkfsCall) Apply

func (mkfs MkfsCall) Apply(console Console) (string, error)

type Partition

type Partition struct {
	Start      uint64
	End        uint64
	Size       uint64
	PLabel     string
	FileSystem string
	FSLabel    string
	PartNumber int
}

func GetParts added in v1.19.0

func GetParts(d *disk.Disk) []Partition

type RealFilesystemDetector added in v1.19.0

type RealFilesystemDetector struct{}

RealFilesystemDetector implements FilesystemDetector using real detection logic.

func (RealFilesystemDetector) DetectFileSystemType added in v1.19.0

func (RealFilesystemDetector) DetectFileSystemType(part *gpt.Partition, d *disk.Disk) (string, error)

type RealGrowFsToMax added in v1.19.0

type RealGrowFsToMax struct{}

RealGrowFsToMax is the real implementation of GrowFsToMaxInterface.

func (*RealGrowFsToMax) GrowFSToMax added in v1.19.0

func (r *RealGrowFsToMax) GrowFSToMax(devicePath, fsType string) error

GrowFSToMax grows the filesystem on the given block device path to the maximum available space in the partition. fsType: "ext4" (works for ext3/ext2 via ext4 driver), "xfs", "btrfs".

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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