v1

package
v2.10.4 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 17 Imported by: 5

Documentation

Index

Constants

View Source
const (
	GPT   = "gpt"
	BIOS  = "bios"
	MSDOS = "msdos"
	EFI   = "efi"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudInitRunner

type CloudInitRunner interface {
	Run(string, ...string) error
	SetModifier(schema.Modifier)
}

type DockerImageMeta

type DockerImageMeta struct {
	Digest string `yaml:"digest,omitempty"`
	Size   int64  `yaml:"size,omitempty"`
}

DockerImageMeta represents metadata of a docker container image type

type ElementalPartitions

type ElementalPartitions struct {
	BIOS       *Partition `yaml:"-"`
	EFI        *Partition `yaml:"-"`
	OEM        *Partition `yaml:"oem,omitempty" mapstructure:"oem"`
	Recovery   *Partition `yaml:"recovery,omitempty" mapstructure:"recovery"`
	State      *Partition `yaml:"state,omitempty" mapstructure:"state"`
	Persistent *Partition `yaml:"persistent,omitempty" mapstructure:"persistent"`
}

func NewElementalPartitionsFromList

func NewElementalPartitionsFromList(pl PartitionList) ElementalPartitions

NewElementalPartitionsFromList fills an ElementalPartitions instance from given partitions list. First tries to match partitions by partition label, if not, it tries to match partitions by default filesystem label TODO find a way to map custom labels when partition labels are not available

func (ElementalPartitions) PartitionsByInstallOrder

func (ep ElementalPartitions) PartitionsByInstallOrder(extraPartitions PartitionList, excludes ...*Partition) PartitionList

PartitionsByInstallOrder sorts partitions according to the default layout nil partitions are ignored partition with 0 size is set last

func (ElementalPartitions) PartitionsByMountPoint

func (ep ElementalPartitions) PartitionsByMountPoint(descending bool, excludes ...*Partition) PartitionList

PartitionsByMountPoint sorts partitions according to its mountpoint, ignores nil partitions or partitions with an empty mountpoint

func (*ElementalPartitions) SetDefaultLabels

func (ep *ElementalPartitions) SetDefaultLabels()

SetDefaultLabels sets the default labels for oem, state, persistent and recovery partitions.

func (*ElementalPartitions) SetFirmwarePartitions

func (ep *ElementalPartitions) SetFirmwarePartitions(firmware string, partTable string) error

SetFirmwarePartitions sets firmware partitions for a given firmware and partition table type

type EmptySpec

type EmptySpec struct {
}

EmptySpec is an empty spec for places that may need to inject a spec but doent really have one associated like firstboot

func (*EmptySpec) Sanitize

func (r *EmptySpec) Sanitize() error

func (*EmptySpec) ShouldReboot

func (r *EmptySpec) ShouldReboot() bool

func (*EmptySpec) ShouldShutdown

func (r *EmptySpec) ShouldShutdown() bool

type FS

type FS interface {
	Open(name string) (fs.File, error)
	Chmod(name string, mode os.FileMode) error
	Create(name string) (*os.File, error)
	Mkdir(name string, perm os.FileMode) error
	Stat(name string) (os.FileInfo, error)
	Lstat(name string) (os.FileInfo, error)
	RemoveAll(path string) error
	ReadFile(filename string) ([]byte, error)
	Readlink(name string) (string, error)
	RawPath(name string) (string, error)
	ReadDir(dirname string) ([]fs.DirEntry, error)
	Remove(name string) error
	OpenFile(name string, flag int, perm fs.FileMode) (*os.File, error)
	WriteFile(filename string, data []byte, perm os.FileMode) error
}

type HTTPClient

type HTTPClient interface {
	GetURL(log sdkTypes.KairosLogger, url string, destination string) error
}

type Image

type Image struct {
	File       string       `yaml:"-"`
	Label      string       `yaml:"label,omitempty" mapstructure:"label"`
	Size       uint         `yaml:"size,omitempty" mapstructure:"size"`
	FS         string       `yaml:"fs,omitempty" mapstructure:"fs"`
	Source     *ImageSource `yaml:"uri,omitempty" mapstructure:"uri"`
	MountPoint string       `yaml:"-"`
	LoopDevice string       `yaml:"-"`
}

Image struct represents a file system image with its commonly configurable values, size in MiB

type ImageExtractor

type ImageExtractor interface {
	ExtractImage(imageRef, destination, platformRef string) error
	GetOCIImageSize(imageRef, platformRef string) (int64, error)
}

type ImageSource

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

ImageSource represents the source from where an image is created for easy identification

func NewDirSrc

func NewDirSrc(src string) *ImageSource

func NewDockerSrc

func NewDockerSrc(src string) *ImageSource

func NewEmptySrc

func NewEmptySrc() *ImageSource

func NewFileSrc

func NewFileSrc(src string) *ImageSource

func NewSrcFromURI

func NewSrcFromURI(uri string) (*ImageSource, error)

func (*ImageSource) CustomUnmarshal

func (i *ImageSource) CustomUnmarshal(data interface{}) (bool, error)

func (ImageSource) IsDir

func (i ImageSource) IsDir() bool

func (ImageSource) IsDocker

func (i ImageSource) IsDocker() bool

func (ImageSource) IsEmpty

func (i ImageSource) IsEmpty() bool

func (ImageSource) IsFile

func (i ImageSource) IsFile() bool

func (ImageSource) MarshalYAML

func (i ImageSource) MarshalYAML() (interface{}, error)

func (ImageSource) String

func (i ImageSource) String() string

func (*ImageSource) UnmarshalYAML

func (i *ImageSource) UnmarshalYAML(value *yaml.Node) error

func (ImageSource) Value

func (i ImageSource) Value() string

type ImageState

type ImageState struct {
	Source         *ImageSource `yaml:"source,omitempty"`
	SourceMetadata interface{}  `yaml:"source-metadata,omitempty"`
	Label          string       `yaml:"label,omitempty"`
	FS             string       `yaml:"fs,omitempty"`
}

ImageState represents data of a deployed image

func (*ImageState) UnmarshalYAML

func (i *ImageState) UnmarshalYAML(value *yaml.Node) error

type InstallSpec

type InstallSpec struct {
	Target          string              `yaml:"device,omitempty" mapstructure:"device"`
	Firmware        string              `yaml:"firmware,omitempty" mapstructure:"firmware"`
	PartTable       string              `yaml:"part-table,omitempty" mapstructure:"part-table"`
	Partitions      ElementalPartitions `yaml:"partitions,omitempty" mapstructure:"partitions"`
	ExtraPartitions PartitionList       `yaml:"extra-partitions,omitempty" mapstructure:"extra-partitions"`
	NoFormat        bool                `yaml:"no-format,omitempty" mapstructure:"no-format"`
	Force           bool                `yaml:"force,omitempty" mapstructure:"force"`
	CloudInit       []string            `yaml:"cloud-init,omitempty" mapstructure:"cloud-init"`
	Iso             string              `yaml:"iso,omitempty" mapstructure:"iso"`
	GrubDefEntry    string              `yaml:"grub-entry-name,omitempty" mapstructure:"grub-entry-name"`
	Tty             string              `yaml:"tty,omitempty" mapstructure:"tty"`
	Reboot          bool                `yaml:"reboot,omitempty" mapstructure:"reboot"`
	PowerOff        bool                `yaml:"poweroff,omitempty" mapstructure:"poweroff"`
	ExtraDirsRootfs []string            `yaml:"extra-dirs-rootfs,omitempty" mapstructure:"extra-dirs-rootfs"`
	Active          Image               `yaml:"system,omitempty" mapstructure:"system"`
	Recovery        Image               `yaml:"recovery-system,omitempty" mapstructure:"recovery-system"`
	Passive         Image
	GrubConf        string
}

InstallSpec struct represents all the installation action details

func (*InstallSpec) GetExtraPartitions

func (i *InstallSpec) GetExtraPartitions() PartitionList

func (*InstallSpec) GetPartTable

func (i *InstallSpec) GetPartTable() string

func (*InstallSpec) GetPartitions

func (i *InstallSpec) GetPartitions() ElementalPartitions

func (*InstallSpec) GetTarget

func (i *InstallSpec) GetTarget() string

func (*InstallSpec) Sanitize

func (i *InstallSpec) Sanitize() error

Sanitize checks the consistency of the struct, returns error if unsolvable inconsistencies are found

func (*InstallSpec) ShouldReboot

func (i *InstallSpec) ShouldReboot() bool

func (*InstallSpec) ShouldShutdown

func (i *InstallSpec) ShouldShutdown() bool

type InstallState

type InstallState struct {
	Date       string                     `yaml:"date,omitempty"`
	Partitions map[string]*PartitionState `yaml:",omitempty,inline"`
}

InstallState tracks the installation data of the whole system

type InstallUkiSpec

type InstallUkiSpec struct {
	Active          Image               `yaml:"system,omitempty" mapstructure:"system"`
	Target          string              `yaml:"device,omitempty" mapstructure:"device"`
	Reboot          bool                `yaml:"reboot,omitempty" mapstructure:"reboot"`
	PowerOff        bool                `yaml:"poweroff,omitempty" mapstructure:"poweroff"`
	Partitions      ElementalPartitions `yaml:"partitions,omitempty" mapstructure:"partitions"`
	ExtraPartitions PartitionList       `yaml:"extra-partitions,omitempty" mapstructure:"extra-partitions"`
	NoFormat        bool                `yaml:"no-format,omitempty" mapstructure:"no-format"`
	CloudInit       []string            `yaml:"cloud-init,omitempty" mapstructure:"cloud-init"`
	SkipEntries     []string            `yaml:"skip-entries,omitempty" mapstructure:"skip-entries"`
}

func (*InstallUkiSpec) GetExtraPartitions

func (i *InstallUkiSpec) GetExtraPartitions() PartitionList

func (*InstallUkiSpec) GetPartTable

func (i *InstallUkiSpec) GetPartTable() string

func (*InstallUkiSpec) GetPartitions

func (i *InstallUkiSpec) GetPartitions() ElementalPartitions

func (*InstallUkiSpec) GetTarget

func (i *InstallUkiSpec) GetTarget() string

func (*InstallUkiSpec) Sanitize

func (i *InstallUkiSpec) Sanitize() error

func (*InstallUkiSpec) ShouldReboot

func (i *InstallUkiSpec) ShouldReboot() bool

func (*InstallUkiSpec) ShouldShutdown

func (i *InstallUkiSpec) ShouldShutdown() bool

type OCIImageExtractor

type OCIImageExtractor struct{}

func (OCIImageExtractor) ExtractImage

func (e OCIImageExtractor) ExtractImage(imageRef, destination, platformRef string) error

func (OCIImageExtractor) GetOCIImageSize

func (e OCIImageExtractor) GetOCIImageSize(imageRef, platformRef string) (int64, error)

type Partition

type Partition struct {
	Name            string   `yaml:"-"`
	FilesystemLabel string   `yaml:"label,omitempty" mapstructure:"label"`
	Size            uint     `yaml:"size,omitempty" mapstructure:"size"`
	FS              string   `yaml:"fs,omitempty" mapstrcuture:"fs"`
	Flags           []string `yaml:"flags,omitempty" mapstrcuture:"flags"`
	MountPoint      string   `yaml:"-"`
	Path            string   `yaml:"-"`
	Disk            string   `yaml:"-"`
}

Partition struct represents a partition with its commonly configurable values, size in MiB

type PartitionList

type PartitionList []*Partition

func (PartitionList) GetByLabel

func (pl PartitionList) GetByLabel(label string) *Partition

GetByLabel gets a partition by its label from the PartitionList

func (PartitionList) GetByName

func (pl PartitionList) GetByName(name string) *Partition

GetByName gets a partitions by its name from the PartitionList

type PartitionState

type PartitionState struct {
	FSLabel string                 `yaml:"label,omitempty"`
	Images  map[string]*ImageState `yaml:",omitempty,inline"`
}

PartitionState tracks installation data of a partition

type Platform

type Platform struct {
	OS         string
	Arch       string
	GolangArch string
}

func NewPlatform

func NewPlatform(os, arch string) (*Platform, error)

func NewPlatformFromArch

func NewPlatformFromArch(arch string) (*Platform, error)

func ParsePlatform

func ParsePlatform(platform string) (*Platform, error)

func (*Platform) CustomUnmarshal

func (p *Platform) CustomUnmarshal(data interface{}) (bool, error)

func (Platform) MarshalYAML

func (p Platform) MarshalYAML() (interface{}, error)

func (*Platform) String

func (p *Platform) String() string

func (*Platform) UnmarshalYAML

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

type RealRunner

type RealRunner struct {
	Logger *sdkTypes.KairosLogger
}

func (*RealRunner) GetLogger

func (r *RealRunner) GetLogger() *sdkTypes.KairosLogger

func (RealRunner) InitCmd

func (r RealRunner) InitCmd(command string, args ...string) *exec.Cmd

func (RealRunner) Run

func (r RealRunner) Run(command string, args ...string) ([]byte, error)

func (RealRunner) RunCmd

func (r RealRunner) RunCmd(cmd *exec.Cmd) ([]byte, error)

func (*RealRunner) SetLogger

func (r *RealRunner) SetLogger(logger *sdkTypes.KairosLogger)

type RealSyscall

type RealSyscall struct{}

func (*RealSyscall) Chdir

func (r *RealSyscall) Chdir(path string) error

func (*RealSyscall) Chroot

func (r *RealSyscall) Chroot(path string) error

func (*RealSyscall) Mount added in v2.7.13

func (r *RealSyscall) Mount(source string, target string, fstype string, flags uintptr, data string) error

type ResetSpec

type ResetSpec struct {
	FormatPersistent bool     `yaml:"reset-persistent,omitempty" mapstructure:"reset-persistent"`
	FormatOEM        bool     `yaml:"reset-oem,omitempty" mapstructure:"reset-oem"`
	Reboot           bool     `yaml:"reboot,omitempty" mapstructure:"reboot"`
	PowerOff         bool     `yaml:"poweroff,omitempty" mapstructure:"poweroff"`
	GrubDefEntry     string   `yaml:"grub-entry-name,omitempty" mapstructure:"grub-entry-name"`
	Tty              string   `yaml:"tty,omitempty" mapstructure:"tty"`
	ExtraDirsRootfs  []string `yaml:"extra-dirs-rootfs,omitempty" mapstructure:"extra-dirs-rootfs"`
	Active           Image    `yaml:"system,omitempty" mapstructure:"system"`
	Passive          Image
	Partitions       ElementalPartitions
	Target           string
	Efi              bool
	GrubConf         string
	State            *InstallState
}

ResetSpec struct represents all the reset action details

func (*ResetSpec) Sanitize

func (r *ResetSpec) Sanitize() error

Sanitize checks the consistency of the struct, returns error if unsolvable inconsistencies are found

func (*ResetSpec) ShouldReboot

func (r *ResetSpec) ShouldReboot() bool

func (*ResetSpec) ShouldShutdown

func (r *ResetSpec) ShouldShutdown() bool

type ResetUkiSpec

type ResetUkiSpec struct {
	FormatPersistent bool `yaml:"reset-persistent,omitempty" mapstructure:"reset-persistent"`
	FormatOEM        bool `yaml:"reset-oem,omitempty" mapstructure:"reset-oem"`
	Reboot           bool `yaml:"reboot,omitempty" mapstructure:"reboot"`
	PowerOff         bool `yaml:"poweroff,omitempty" mapstructure:"poweroff"`
	Partitions       ElementalPartitions
}

func (*ResetUkiSpec) Sanitize

func (i *ResetUkiSpec) Sanitize() error

func (*ResetUkiSpec) ShouldReboot

func (i *ResetUkiSpec) ShouldReboot() bool

func (*ResetUkiSpec) ShouldShutdown

func (i *ResetUkiSpec) ShouldShutdown() bool

type Runner

type Runner interface {
	InitCmd(string, ...string) *exec.Cmd
	Run(string, ...string) ([]byte, error)
	RunCmd(cmd *exec.Cmd) ([]byte, error)
	GetLogger() *sdkTypes.KairosLogger
	SetLogger(logger *sdkTypes.KairosLogger)
}

type SharedInstallSpec

type SharedInstallSpec interface {
	GetPartTable() string
	GetTarget() string
	GetPartitions() ElementalPartitions
	GetExtraPartitions() PartitionList
}

SharedInstallSpec is the interface that Install specs need to implement

type SourceNotFound

type SourceNotFound struct {
}

SourceNotFound is the error to raise when we can't find a source for install/upgrade

func (*SourceNotFound) Error

func (s *SourceNotFound) Error() string

type Spec

type Spec interface {
	Sanitize() error
	ShouldReboot() bool
	ShouldShutdown() bool
}

type SyscallInterface

type SyscallInterface interface {
	Chroot(string) error
	Chdir(string) error
	Mount(string, string, string, uintptr, string) error
}

type UpgradeSpec

type UpgradeSpec struct {
	RecoveryUpgrade bool     `yaml:"recovery,omitempty" mapstructure:"recovery"`
	Active          Image    `yaml:"system,omitempty" mapstructure:"system"`
	Recovery        Image    `yaml:"recovery-system,omitempty" mapstructure:"recovery-system"`
	GrubDefEntry    string   `yaml:"grub-entry-name,omitempty" mapstructure:"grub-entry-name"`
	Reboot          bool     `yaml:"reboot,omitempty" mapstructure:"reboot"`
	PowerOff        bool     `yaml:"poweroff,omitempty" mapstructure:"poweroff"`
	ExtraDirsRootfs []string `yaml:"extra-dirs-rootfs,omitempty" mapstructure:"extra-dirs-rootfs"`
	Passive         Image
	Partitions      ElementalPartitions
	State           *InstallState
}

func (*UpgradeSpec) Sanitize

func (u *UpgradeSpec) Sanitize() error

Sanitize checks the consistency of the struct, returns error if unsolvable inconsistencies are found

func (*UpgradeSpec) ShouldReboot

func (u *UpgradeSpec) ShouldReboot() bool

func (*UpgradeSpec) ShouldShutdown

func (u *UpgradeSpec) ShouldShutdown() bool

type UpgradeUkiSpec

type UpgradeUkiSpec struct {
	RecoveryUpgrade bool       `yaml:"recovery,omitempty" mapstructure:"recovery"`
	Active          Image      `yaml:"system,omitempty" mapstructure:"system"`
	Reboot          bool       `yaml:"reboot,omitempty" mapstructure:"reboot"`
	PowerOff        bool       `yaml:"poweroff,omitempty" mapstructure:"poweroff"`
	EfiPartition    *Partition `yaml:"efi-partition,omitempty" mapstructure:"efi-partition"`
}

func (*UpgradeUkiSpec) Sanitize

func (i *UpgradeUkiSpec) Sanitize() error

func (*UpgradeUkiSpec) ShouldReboot

func (i *UpgradeUkiSpec) ShouldReboot() bool

func (*UpgradeUkiSpec) ShouldShutdown

func (i *UpgradeUkiSpec) ShouldShutdown() bool

Jump to

Keyboard shortcuts

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