initrd

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package initrd builds the initramfs a guest boots from, carrying dicer-init and dicer-agent. It is rebuilt only when the embedded binaries change.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Puller fetches the base image the initramfs is built from.
	Puller Puller

	// DataDir is the daemon's data directory; initrds are kept under its
	// initrd directory. Required.
	DataDir string

	// BaseImage is the image the initramfs is built from. Empty is
	// alpine:3.21.
	BaseImage string

	// Logger is where progress is logged. Nil is slog.Default.
	Logger *slog.Logger
}

Config configures an initrd Manager.

type Manager

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

Manager builds the initrd and keeps it on disk. It is safe for concurrent use.

func NewManager

func NewManager(cfg Config) (*Manager, error)

NewManager returns a Manager, refusing a Config without a Puller or a DataDir.

func (*Manager) Prepare

func (m *Manager) Prepare(ctx context.Context) (string, error)

Prepare ensures the initrd for the host's architecture exists and matches the embedded binaries, building it if necessary, and returns its path. The path is the same for every build, so a hypervisor that reopens it -- as Cloud Hypervisor does on a guest reboot and on restoring a snapshot -- always finds a complete initrd.

type Puller

type Puller interface {
	Resolve(ctx context.Context, ref *reference.Ref) (string, error)
	PullAndExport(
		ctx context.Context, imageRef, digest, exportDir string, onProgress registry.ProgressFunc,
	) (*registry.Metadata, error)
}

Puller is the registry the base image of an initrd is pulled from.

Jump to

Keyboard shortcuts

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