imagecustomizerapi

package
v0.0.0-...-59ce246 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 13 Imported by: 0

README

Mariner Image Customizer API

The Mariner image customizer (imgcustomizer) will be released as a standalone tool and will provide strong backwards compatibility guarantees (after the first official release). This is contrast to the Mariner toolkit's new image config, which isn't officially released and doesn't provide any backwards compatibility guarantees.

While currently the new image config and imgcustomizer config are very similar, in the future there is the possibility they will diverge.

Known differences

  • For the new image config, AdditionalFiles' source files are relative to the working directory. Whereas, for imgcustomizer, the source files are relative to the config file.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultFileConfig = FileConfig{
		Path:        "",
		Permissions: nil,
	}
)

Functions

func UnmarshalYaml

func UnmarshalYaml[ValueType HasIsValid](yamlData []byte, value ValueType) error

func UnmarshalYamlFile

func UnmarshalYamlFile[ValueType HasIsValid](yamlFilePath string, value ValueType) error

Types

type BootType

type BootType string
const (
	BootTypeEfi    BootType = "efi"
	BootTypeLegacy BootType = "legacy"
	BootTypeUnset  BootType = ""
)

func (BootType) IsValid

func (t BootType) IsValid() error

type Config

type Config struct {
	Disks        *[]Disk      `yaml:"Disks"`
	SystemConfig SystemConfig `yaml:"SystemConfig"`
}

func (*Config) IsValid

func (c *Config) IsValid() error

type Disk

type Disk struct {
	// The type of partition table to use (e.g. mbr, gpt)
	PartitionTableType PartitionTableType `yaml:"PartitionTableType"`

	// The virtual size of the disk.
	MaxSize uint64 `yaml:"MaxSize"`

	// The partitions to allocate on the disk.
	Partitions []Partition `yaml:"Partitions"`
}

func (*Disk) IsValid

func (d *Disk) IsValid() error

type FileConfig

type FileConfig struct {
	// The file path in the target OS that the file will be copied to.
	Path string `yaml:"Path"`

	// The file permissions to set on the file.
	Permissions *FilePermissions `yaml:"Permissions"`
}

FileConfig specifies options for how a file is copied in the target OS.

func (*FileConfig) IsValid

func (f *FileConfig) IsValid() (err error)

func (*FileConfig) UnmarshalYAML

func (f *FileConfig) UnmarshalYAML(value *yaml.Node) error

type FileConfigList

type FileConfigList []FileConfig

DestinationFileConfigList is a list of destination files where the source file will be copied to in the final image. This type exists to allow a custom marshaller to be attached to it.

func (*FileConfigList) IsValid

func (l *FileConfigList) IsValid() (err error)

func (*FileConfigList) UnmarshalYAML

func (l *FileConfigList) UnmarshalYAML(value *yaml.Node) error

type FilePermissions

type FilePermissions os.FileMode

The file permissions to set on the file.

Accepted formats:

- Octal string (e.g. "660")

func (*FilePermissions) IsValid

func (p *FilePermissions) IsValid() error

func (*FilePermissions) UnmarshalYAML

func (p *FilePermissions) UnmarshalYAML(value *yaml.Node) error

type FileSystemType

type FileSystemType string

FileSystemType is a type of file system (e.g. ext4, xfs, etc.)

const (
	FileSystemTypeExt4  FileSystemType = "ext4"
	FileSystemTypeXfs   FileSystemType = "xfs"
	FileSystemTypeFat32 FileSystemType = "fat32"
)

func (FileSystemType) IsValid

func (t FileSystemType) IsValid() error

type HasIsValid

type HasIsValid interface {
	IsValid() error
}

type IdType

type IdType string
const (
	IdTypePartLabel IdType = "PartLabel"
	IdTypeUuid      IdType = "Uuid"
	IdTypePartUuid  IdType = "PartUuid"
)

func (IdType) IsValid

func (i IdType) IsValid() error

type KernelCommandLine

type KernelCommandLine struct {
	// Extra kernel command line args.
	ExtraCommandLine string `yaml:"ExtraCommandLine"`
}

func (*KernelCommandLine) IsValid

func (s *KernelCommandLine) IsValid() error

type Module

type Module struct {
	Name string `yaml:"Name"`
}

func (*Module) IsValid

func (m *Module) IsValid() error

type Modules

type Modules struct {
	Load    []Module `yaml:"Load"`
	Disable []Module `yaml:"Disable"`
}

func (*Modules) IsValid

func (m *Modules) IsValid() error

type MountIdentifierType

type MountIdentifierType string

MountIdentifierType indicates how a partition should be identified in the fstab file

const (
	// MountIdentifierTypeUuid mounts this partition via the filesystem UUID
	MountIdentifierTypeUuid MountIdentifierType = "uuid"

	// MountIdentifierTypePartUuid mounts this partition via the GPT/MBR PARTUUID
	MountIdentifierTypePartUuid MountIdentifierType = "partuuid"

	// MountIdentifierTypePartLabel mounts this partition via the GPT PARTLABEL
	MountIdentifierTypePartLabel MountIdentifierType = "partlabel"

	// MountIdentifierTypeDefault uses the default type, which is PARTUUID.
	MountIdentifierTypeDefault MountIdentifierType = ""
)

func (MountIdentifierType) IsValid

func (m MountIdentifierType) IsValid() error

type PackageList

type PackageList struct {
	Packages []string `yaml:"Packages"`
}

func (*PackageList) IsValid

func (s *PackageList) IsValid() error

type Partition

type Partition struct {
	// ID is used to correlate `Partition` objects with `PartitionSetting` objects.
	ID string `yaml:"ID"`
	// FsType is the type of file system to use on the partition.
	FsType FileSystemType `yaml:"FsType"`
	// Name is the label to assign to the partition.
	Name string `yaml:"Name"`
	// Start is the offset where the partition begins (inclusive), in MiBs.
	Start uint64 `yaml:"Start"`
	// End is the offset where the partition ends (exclusive), in MiBs.
	End *uint64 `yaml:"End"`
	// Size is the size of the partition in MiBs.
	Size *uint64 `yaml:"Size"`
	// Flags assigns features to the partition.
	Flags []PartitionFlag `yaml:"Flags"`
}

func (*Partition) GetEnd

func (p *Partition) GetEnd() (uint64, bool)

func (*Partition) IsValid

func (p *Partition) IsValid() error

type PartitionFlag

type PartitionFlag string

PartitionFlag describes the features of a partition.

const (
	// PartitionFlagEsp indicates this is a UEFI System Partition (ESP).
	//
	// On GPT disks, "boot" and "esp" must always be specified together.
	PartitionFlagESP PartitionFlag = "esp"

	// PartitionFlagBiosGrub indicates this is the BIOS boot partition.
	// This is required for GPT disks that wish to be bootable using legacy BIOS mode.
	// This partition must start at block 1.
	//
	// See, https://en.wikipedia.org/wiki/BIOS_boot_partition
	PartitionFlagBiosGrub PartitionFlag = "bios_grub"

	// PartitionFlagBoot indicates this is a boot partition.
	//
	// On GPT disks, "boot" and "esp" must always be specified together.
	PartitionFlagBoot PartitionFlag = "boot"
)

func (PartitionFlag) IsValid

func (p PartitionFlag) IsValid() (err error)

type PartitionSetting

type PartitionSetting struct {
	ID              string              `yaml:"ID"`
	MountIdentifier MountIdentifierType `yaml:"MountIdentifier"`
	MountOptions    string              `yaml:"MountOptions"`
	MountPoint      string              `yaml:"MountPoint"`
}

PartitionSetting holds the mounting information for each partition.

func (*PartitionSetting) IsValid

func (p *PartitionSetting) IsValid() error

IsValid returns an error if the PartitionSetting is not valid

type PartitionTableType

type PartitionTableType string

PartitionTableType is either gpt, mbr, or none

const (
	PartitionTableTypeGpt PartitionTableType = "gpt"
)

func (PartitionTableType) IsValid

func (t PartitionTableType) IsValid() error

type Script

type Script struct {
	Path string `yaml:"Path"`
	Args string `yaml:"Args"`
}

func (*Script) IsValid

func (s *Script) IsValid() error

type Service

type Service struct {
	Name string `yaml:"Name"`
}

func (*Service) IsValid

func (s *Service) IsValid() error

type Services

type Services struct {
	Enable  []Service `yaml:"Enable"`
	Disable []Service `yaml:"Disable"`
}

func (*Services) IsValid

func (s *Services) IsValid() error

type SystemConfig

type SystemConfig struct {
	BootType                BootType                  `yaml:"BootType"`
	Hostname                string                    `yaml:"Hostname"`
	UpdateBaseImagePackages bool                      `yaml:"UpdateBaseImagePackages"`
	PackageListsInstall     []string                  `yaml:"PackageListsInstall"`
	PackagesInstall         []string                  `yaml:"PackagesInstall"`
	PackageListsRemove      []string                  `yaml:"PackageListsRemove"`
	PackagesRemove          []string                  `yaml:"PackagesRemove"`
	PackageListsUpdate      []string                  `yaml:"PackageListsUpdate"`
	PackagesUpdate          []string                  `yaml:"PackagesUpdate"`
	KernelCommandLine       KernelCommandLine         `yaml:"KernelCommandLine"`
	AdditionalFiles         map[string]FileConfigList `yaml:"AdditionalFiles"`
	PartitionSettings       []PartitionSetting        `yaml:"PartitionSettings"`
	PostInstallScripts      []Script                  `yaml:"PostInstallScripts"`
	FinalizeImageScripts    []Script                  `yaml:"FinalizeImageScripts"`
	Users                   []User                    `yaml:"Users"`
	Services                Services                  `yaml:"Services"`
	Modules                 Modules                   `yaml:"Modules"`
	Verity                  *Verity                   `yaml:"Verity"`
}

SystemConfig defines how each system present on the image is supposed to be configured.

func (*SystemConfig) IsValid

func (s *SystemConfig) IsValid() error

type User

type User struct {
	Name                string   `yaml:"Name"`
	UID                 *int     `yaml:"UID"`
	PasswordHashed      bool     `yaml:"PasswordHashed"`
	Password            string   `yaml:"Password"`
	PasswordPath        string   `yaml:"PasswordPath"`
	PasswordExpiresDays *int64   `yaml:"PasswordExpiresDays"`
	SSHPubKeyPaths      []string `yaml:"SSHPubKeyPaths"`
	SSHPubKeys          []string `yaml:"SSHPubKeys"`
	PrimaryGroup        string   `yaml:"PrimaryGroup"`
	SecondaryGroups     []string `yaml:"SecondaryGroups"`
	StartupCommand      string   `yaml:"StartupCommand"`
}

func (*User) IsValid

func (u *User) IsValid() error

type Verity

type Verity struct {
	DataPartition VerityPartition `yaml:"DataPartition"`
	HashPartition VerityPartition `yaml:"HashPartition"`
}

func (*Verity) IsValid

func (v *Verity) IsValid() error

type VerityPartition

type VerityPartition struct {
	IdType IdType `yaml:"IdType"`
	Id     string `yaml:"Id"`
}

func (*VerityPartition) IsValid

func (v *VerityPartition) IsValid() error

Jump to

Keyboard shortcuts

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