Documentation
¶
Overview ¶
Package bootstrap builds a Hardware's OSIE files into an uncompressed `newc` CPIO archive, which the kernel extracts as an additional initramfs, and serves it over HTTP.
Index ¶
Constants ¶
const ArchiveName = "bootstrap.cpio"
ArchiveName is the file name the Handler serves.
const DefaultMode = 0o400
DefaultMode is applied to files that do not specify one. Delivered files are read-only to their owner because they routinely carry credentials.
const Dir = "osie_files"
Dir is where the delivered files land in the initramfs, relative to its root. A dedicated top-level path, so it survives the OSIE (CaptainOS's) rootfs-to-tmpfs transition (its init does cp -ax) and is not hidden by a later mount.
Variables ¶
This section is empty.
Functions ¶
func Archive ¶
Archive serializes files into an uncompressed `newc` CPIO archive.
Parent directory entries are synthesized and deduplicated, entries are emitted in a deterministic order, and the archive is terminated with the mandatory TRAILER!!! entry.
modTime is stamped on every entry. It must be stable for a given set of files: the archive is regenerated per HTTP request, and a BMC assembles one ISO mount from thousands of range requests, so a moving clock would splice mismatched headers together. A zero time yields the epoch.
func ModTime ¶
func ModTime(hw *tinkerbell.Hardware) time.Time
ModTime is the timestamp stamped on the delivered files.
The Hardware's creation time is used because it is stable for the life of the object; see Archive for why a live clock cannot be. It does not move when the files themselves are edited.
Types ¶
type BackendReader ¶
type BackendReader interface {
FilterHardware(ctx context.Context, opts data.HardwareFilter) (*tinkerbell.Hardware, error)
}
BackendReader is the interface for getting hardware data from a backend.
type File ¶
type File struct {
// Name is the archive-relative path, e.g. "osie_files/network/config.json".
// A leading "/" is stripped; the kernel extracts relative to the initramfs root.
Name string
// Mode holds the permission bits, at most 0o777. Zero means DefaultMode,
// so a mode of no permissions at all cannot be requested.
Mode uint32
Data []byte
}
File is a single regular file to place in the generated archive.
func Files ¶
func Files(hw *tinkerbell.Hardware) ([]File, error)
Files returns the per-host files to deliver.
Content is entirely user defined: every file comes from the Hardware's spec.metadata.osieFiles, placed under Dir. Nothing is synthesized, so a Hardware with no files produces an empty archive.
type Handler ¶
type Handler struct {
Logger logr.Logger
Backend BackendReader
}
Handler serves a Hardware's archive over HTTP, looked up by MAC address.
func (*Handler) HandlerFunc ¶
func (h *Handler) HandlerFunc() http.HandlerFunc
HandlerFunc returns a handler for paths ending in <mac>/bootstrap.cpio.