Documentation
¶
Index ¶
- Constants
- func Build(path string, nameservers, dnsSearch, dnsOptions []string) error
- func Commands(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func DNS(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func DataSources(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func DecodeMultipartVmware(data []byte) []byte
- func DeleteEntities(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func Download(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func EnsureDirectories(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func EnsureFiles(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func Entities(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func Environment(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func Git(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func Hostname(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func IfArch(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func IfConditional(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func IfFiles(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func IfServiceManager(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func Layout(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func LoadModules(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func MiBToSectors(size uint64, sectorSize uint64) uint64
- func NodeConditional(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func OnlyIfOS(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func OnlyIfOSVersion(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func PackagePins(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func Packages(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func PartitionNumberFromDevice(devPath string) (int, error)
- func ResolveScriptDevice(path string) (string, error)
- func SSH(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func Sysctl(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func SystemHostname(hostname string, fs vfs.FS) error
- func Systemctl(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func SystemdFirstboot(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func Timesyncd(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func UnpackImage(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- func UpdateHostsFile(hostname string, fs vfs.FS) error
- func User(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
- type Console
- type Disk
- func (dev *Disk) AddPartitions(parts []schema.Partition, l logger.Interface, console Console) error
- func (dev *Disk) CheckDiskFreeSpaceMiB(minSpace uint64) bool
- func (dev *Disk) ExpandLastPartition(l logger.Interface, size uint64, console Console) error
- func (dev *Disk) MatchPartitionFSLabel(label string) bool
- func (dev *Disk) MatchPartitionPLabel(label string) bool
- func (dev *Disk) VerifyAndRepairHeaders(l logger.Interface)
- type Distro
- type FilesystemDetector
- type GrowFsToMaxInterface
- type HomeDirResolver
- type Installer
- type ItsImageFileError
- type MkfsCall
- type Partition
- type RealFilesystemDetector
- type RealGrowFsToMax
Constants ¶
const ( OneMiBInBytes = 1024 * 1024 Ext4 = "ext4" Ext3 = "ext3" Ext2 = "ext2" Fat = "fat" Vfat = "vfat" Fat32 = "fat32" Fat16 = "fat16" Xfs = "xfs" Btrfs = "btrfs" Swap = "swap" NoFormat = "noformat" )
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 )
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 = "" )
const RunOnlyOs = "running stage (OnlyIfOs regex (%s)"
const RunOnlyOsVersion = "running stage (OnlyIfOsVersion regex (%s)"
const SkipBothServices = "both systemd and openrc are available, cant filter"
const SkipNotSupportedServiceManager = "service manager %s is not supported"
const SkipOnlyArch = "arch %s doesn't match %s"
const SkipOnlyOs = "OnlyIfOs regex (%s)"
const SkipOnlyOsVersion = "OnlyIfOsVersion regex (%s)"
const SkipOnlyServiceManager = "service manager doesn't match %s"
Variables ¶
This section is empty.
Functions ¶
func DataSources ¶
func DecodeMultipartVmware ¶ added in v1.3.1
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 EnsureDirectories ¶
func EnsureFiles ¶
func Environment ¶
func IfArch ¶ added in v1.14.1
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 IfServiceManager ¶ added in v1.14.1
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 LoadModules ¶
func MiBToSectors ¶
func NodeConditional ¶
func OnlyIfOS ¶ added in v1.14.0
OnlyIfOS checks if the OS matches the if statement and runs it if so
func OnlyIfOSVersion ¶ added in v1.14.0
OnlyIfOSVersion checks if the OS VERSION matches the if statement and runs it if so
func PackagePins ¶ added in v1.22.0
PackagePins applies a best-effort "pin/version lock" policy before package installs.
Supports: - APT (Debian/Ubuntu): /etc/apt/preferences.d/99-yip-pins with Pin-Priority: 1001 - DNF (Fedora/RHEL/etc.): /etc/dnf/plugins/versionlock.conf + locklist file
- resolves strict NEVRA via `dnf repoquery` when possible; falls back to raw patterns if resolution fails
- SUSE (openSUSE/SLE): zypper addlock (tries name=version; falls back to locking name) - Alpine: updates /etc/apk/world to include name=version constraints (idempotent)
Other installers: warn + no-op (extend later).
func Packages ¶ added in v1.13.0
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 PartitionNumberFromDevice ¶ added in v1.25.1
PartitionNumberFromDevice extracts the partition number out of a partition device path, handling both the /dev/sda3 and the /dev/nvme0n1p3 conventions.
func ResolveScriptDevice ¶ added in v1.23.5
ResolveScriptDevice checks if path starts with the "script://" prefix. If so, it executes the remainder as a command and returns the trimmed stdout as the resolved device path. For any other value it returns path unchanged.
func SystemdFirstboot ¶
func UnpackImage ¶ added in v1.14.0
Types ¶
type Disk ¶
func FindDiskFromLabel ¶ added in v1.19.0
func (*Disk) AddPartitions ¶ added in v1.19.0
AddPartitions adds partitions to the disk based on the provided schema.Partition definitions.
func (*Disk) CheckDiskFreeSpaceMiB ¶
func (*Disk) ExpandLastPartition ¶
func (*Disk) MatchPartitionFSLabel ¶ added in v1.19.0
func (*Disk) MatchPartitionPLabel ¶ added in v1.19.0
func (*Disk) VerifyAndRepairHeaders ¶ added in v1.21.1
VerifyAndRepairHeaders VerifyHeaders verifies the GPT headers of the disk and repairs them if needed. Useful when the disk has been created beforehand with a size and then resized (like in cloud images) and the backup GPT header is not at the end of the disk.
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" OracleLinux Distro = "ol" 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
GrowFsToMaxInterface defines an interface for growing filesystems to max size.
var DefaultGrowFsToMax GrowFsToMaxInterface = &RealGrowFsToMax{}
DefaultGrowFsToMax is the default instance of GrowFsToMaxInterface.
type HomeDirResolver ¶ added in v1.25.0
type HomeDirResolver interface {
// Resolve returns the uid and gid owning path and whether it exists.
Resolve(fs vfs.FS, path string) (uid int, gid int, ok bool)
}
HomeDirResolver resolves the numeric uid/gid owning a user's home directory. It exists so that the "reuse the id of the existing home directory" logic can be mocked in tests (setting real file ownership requires root), following the same pattern as DefaultFilesystemDetector/DefaultGrowFsToMax in this package.
var DefaultHomeDirResolver HomeDirResolver = realHomeDirResolver{}
DefaultHomeDirResolver is the resolver used to look up the owner of existing home directories. Tests override it to simulate persistent home directories.
type ItsImageFileError ¶ added in v1.21.1
type ItsImageFileError struct{}
ItsImageFileError is returned when the given path is an image file, not a block device. Its done to identify image files when resolving parent disks from partitions. So we dont runs the rawPath method twice on image files and get a broken path.
func (ItsImageFileError) Error ¶ added in v1.21.1
func (e ItsImageFileError) Error() string
type 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
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".
Source Files
¶
- commands.go
- common.go
- datasource.go
- dir.go
- dns.go
- download.go
- entities.go
- environment.go
- file_decoder.go
- file_gzip_decoder.go
- files.go
- files_base64_decoder.go
- git_go.go
- hostname.go
- if.go
- if_arch.go
- if_files_dirs.go
- if_os.go
- if_service_manager.go
- layout.go
- layout_resizer.go
- modules.go
- network.go
- package_pins.go
- packages.go
- script_device.go
- ssh.go
- sysctl.go
- systemctl.go
- systemd_firstboot.go
- timesyncd.go
- unpack_image.go
- user.go