v1

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func DebugLevel

func DebugLevel() log.Level

func IsDebugLevel

func IsDebugLevel(l Logger) bool

Types

type BuildConfig

type BuildConfig struct {
	Date   bool   `yaml:"date,omitempty" mapstructure:"date"`
	Name   string `yaml:"name,omitempty" mapstructure:"name"`
	OutDir string `yaml:"output,omitempty" mapstructure:"output"`

	// 'inline' and 'squash' labels ensure config fields
	// are embedded from a yaml and map PoV
	Config `yaml:",inline" mapstructure:",squash"`
}

BuildConfig represents the config we need for building isos, raw images, artifacts

func (*BuildConfig) Sanitize

func (b *BuildConfig) Sanitize() error

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

type ChannelImageMeta

type ChannelImageMeta struct {
	Category    string       `yaml:"category,omitempty"`
	Name        string       `yaml:"name,omitempty"`
	Version     string       `yaml:"version,omitempty"`
	FingerPrint string       `yaml:"finger-print,omitempty"`
	Repos       []Repository `yaml:"repositories,omitempty"`
}

ChannelImageMeta represents metadata of a channel image type

type CloudInitRunner

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

type Config

type Config struct {
	Logger                    Logger
	Fs                        FS
	Mounter                   mount.Interface
	Runner                    Runner
	Syscall                   SyscallInterface
	CloudInitRunner           CloudInitRunner
	ImageExtractor            ImageExtractor
	Client                    HTTPClient
	Platform                  *Platform `yaml:"platform,omitempty" mapstructure:"platform"`
	Cosign                    bool      `yaml:"cosign,omitempty" mapstructure:"cosign"`
	Verify                    bool      `yaml:"verify,omitempty" mapstructure:"verify"`
	CosignPubKey              string    `yaml:"cosign-key,omitempty" mapstructure:"cosign-key"`
	LocalImage                bool      `yaml:"local,omitempty" mapstructure:"local"`
	Arch                      string    `yaml:"arch,omitempty" mapstructure:"arch"`
	SquashFsCompressionConfig []string  `yaml:"squash-compression,omitempty" mapstructure:"squash-compression"`
	SquashFsNoCompression     bool      `yaml:"squash-no-compression,omitempty" mapstructure:"squash-no-compression"`
	CloudInitPaths            []string  `yaml:"cloud-init-paths,omitempty" mapstructure:"cloud-init-paths"`
	Strict                    bool      `yaml:"strict,omitempty" mapstructure:"strict"`
}

Config is the struct that includes basic and generic configuration of elemental binary runtime. It mostly includes the interfaces used around many methods in elemental code

func (Config) LoadInstallState

func (c Config) LoadInstallState() (*InstallState, error)

LoadInstallState loads the state.yaml file and unmarshals it to an InstallState object

func (*Config) Sanitize

func (c *Config) Sanitize() error

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

func (Config) WriteInstallState

func (c Config) WriteInstallState(i *InstallState, statePath, recoveryPath string) error

WriteInstallState writes the state.yaml file to the given state and recovery paths

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
	EFI        *Partition
	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, state *InstallState) 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 filesystem label

func (ElementalPartitions) PartitionsByInstallOrder

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

PartitionsByInstallOrder sorts partitions according to the default layout nil partitons 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) SetFirmwarePartitions

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

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

type FS

type FS interface {
	Open(name string) (*os.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) ([]os.FileInfo, 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
	Symlink(oldname, newname string) error
}

type HTTPClient

type HTTPClient interface {
	GetURL(log Logger, url string, destination string) error
}

type Image

type Image struct {
	File       string
	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
	LoopDevice string
}

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

type ImageExtractor added in v0.3.0

type ImageExtractor interface {
	ExtractImage(imageRef, destination, platformRef string, local bool) 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) IsEmpty

func (i ImageSource) IsEmpty() bool

func (ImageSource) IsFile

func (i ImageSource) IsFile() bool

func (ImageSource) IsImage added in v0.3.0

func (i ImageSource) IsImage() 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:"target,omitempty" mapstructure:"target"`
	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"`
	Active           Image               `yaml:"system,omitempty" mapstructure:"system"`
	Recovery         Image               `yaml:"recovery-system,omitempty" mapstructure:"recovery-system"`
	Passive          Image
	GrubConf         string
	DisableBootEntry bool `yaml:"disable-boot-entry,omitempty" mapstructure:"disable-boot-entry"`
}

InstallSpec struct represents all the installation action details

func (InstallSpec) GetGrubLabels added in v0.2.1

func (i InstallSpec) GetGrubLabels() map[string]string

func (*InstallSpec) Sanitize

func (i *InstallSpec) Sanitize() error

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

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 LiveISO

type LiveISO struct {
	RootFS             []*ImageSource `yaml:"rootfs,omitempty" mapstructure:"rootfs"`
	UEFI               []*ImageSource `yaml:"uefi,omitempty" mapstructure:"uefi"`
	Image              []*ImageSource `yaml:"image,omitempty" mapstructure:"image"`
	Label              string         `yaml:"label,omitempty" mapstructure:"label"`
	GrubEntry          string         `yaml:"grub-entry-name,omitempty" mapstructure:"grub-entry-name"`
	BootloaderInRootFs bool           `yaml:"bootloader-in-rootfs" mapstructure:"bootloader-in-rootfs"`
	Firmware           string         `yaml:"firmware,omitempty" mapstructure:"firmware"`
}

LiveISO represents the configurations needed for a live ISO image

func (*LiveISO) Sanitize

func (i *LiveISO) Sanitize() error

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

type Logger

type Logger interface {
	Info(...interface{})
	Warn(...interface{})
	Debug(...interface{})
	Error(...interface{})
	Fatal(...interface{})
	Success(...interface{})
	Warning(...interface{})
	Panic(...interface{})
	Trace(...interface{})
	Infof(string, ...interface{})
	Warnf(string, ...interface{})
	Debugf(string, ...interface{})
	Errorf(string, ...interface{})
	Fatalf(string, ...interface{})
	Panicf(string, ...interface{})
	Tracef(string, ...interface{})
	SetLevel(level log.Level)
	GetLevel() log.Level
	SetOutput(writer io.Writer)
	SetFormatter(formatter log.Formatter)

	SetContext(string)
	SpinnerStop()
	Spinner()
	Ask() bool
	Screen(string)
}

Logger is the interface we want for our logger, so we can plug different ones easily

func NewBufferLogger

func NewBufferLogger(b *bytes.Buffer) Logger

NewBufferLogger will return a logger that stores all logs in a buffer, used mainly for testing

func NewLogger

func NewLogger() Logger

func NewNullLogger

func NewNullLogger() Logger

NewNullLogger will return a logger that discards all logs, used mainly for testing

type LoggerOptions

type LoggerOptions func(l Logger) error

type OCIImageExtractor added in v0.3.0

type OCIImageExtractor struct{}

func (OCIImageExtractor) ExtractImage added in v0.3.0

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

type Partition

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

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

func (PartitionList) GetByNameOrLabel added in v0.1.3

func (pl PartitionList) GetByNameOrLabel(name, label string) *Partition

GetByNameOrLabel gets a partition by its name or label. It tries by name first

type PartitionState

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

PartState tracks installation data of a partition

type Platform added in v0.3.0

type Platform struct {
	OS         string
	Arch       string
	GolangArch string
}

func NewPlatform added in v0.3.0

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

func NewPlatformFromArch added in v0.3.0

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

func ParsePlatform added in v0.3.0

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

func (*Platform) CustomUnmarshal added in v0.3.0

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

func (Platform) MarshalYAML added in v0.3.0

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

func (*Platform) String added in v0.3.0

func (p *Platform) String() string

func (*Platform) UnmarshalYAML added in v0.3.0

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

type RealRunner

type RealRunner struct {
	Logger Logger
}

func (RealRunner) CommandExists added in v0.2.1

func (r RealRunner) CommandExists(command string) bool

func (RealRunner) GetLogger

func (r RealRunner) GetLogger() Logger

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 Logger)

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

type Repository

type Repository struct {
	Name        string `yaml:"name,omitempty" mapstructure:"name"`
	Priority    int    `yaml:"priority,omitempty" mapstructure:"priority"`
	URI         string `yaml:"uri,omitempty" mapstructure:"uri"`
	Type        string `yaml:"type,omitempty" mapstructure:"type"`
	Arch        string `yaml:"arch,omitempty" mapstructure:"arch"`
	ReferenceID string `yaml:"reference,omitempty" mapstructure:"reference"`
}

Repository represents the basic configuration for a package repository

type ResetSpec

type ResetSpec struct {
	FormatPersistent bool `yaml:"reset-persistent,omitempty" mapstructure:"reset-persistent"`
	FormatOEM        bool `yaml:"reset-oem,omitempty" mapstructure:"reset-oem"`

	GrubDefEntry     string `yaml:"grub-entry-name,omitempty" mapstructure:"grub-entry-name"`
	Active           Image  `yaml:"system,omitempty" mapstructure:"system"`
	Passive          Image
	Partitions       ElementalPartitions
	Target           string
	Efi              bool
	GrubConf         string
	State            *InstallState
	DisableBootEntry bool `yaml:"disable-boot-entry,omitempty" mapstructure:"disable-boot-entry"`
}

ResetSpec struct represents all the reset action details

func (ResetSpec) GetGrubLabels added in v0.2.1

func (r ResetSpec) GetGrubLabels() map[string]string

func (*ResetSpec) Sanitize

func (r *ResetSpec) Sanitize() error

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

type RunConfig

type RunConfig struct {
	Reboot   bool `yaml:"reboot,omitempty" mapstructure:"reboot"`
	PowerOff bool `yaml:"poweroff,omitempty" mapstructure:"poweroff"`
	EjectCD  bool `yaml:"eject-cd,omitempty" mapstructure:"eject-cd"`

	// 'inline' and 'squash' labels ensure config fields
	// are embedded from a yaml and map PoV
	Config `yaml:",inline" mapstructure:",squash"`
}

func (*RunConfig) Sanitize

func (r *RunConfig) Sanitize() error

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

type Runner

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

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 SyscallInterface

type SyscallInterface interface {
	Chroot(string) error
	Chdir(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"`
	Passive         Image
	Partitions      ElementalPartitions
	State           *InstallState
}

func (UpgradeSpec) GetGrubLabels added in v0.2.1

func (u UpgradeSpec) GetGrubLabels() map[string]string

func (*UpgradeSpec) Sanitize

func (u *UpgradeSpec) Sanitize() error

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

Jump to

Keyboard shortcuts

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