Documentation ¶
Index ¶
- Constants
- func DebugLevel() log.Level
- func IsDebugLevel(l Logger) bool
- type BuildConfig
- type ChannelImageMeta
- type CloudInitRunner
- type Config
- type DiskSpec
- type DockerImageMeta
- type ElementalPartitions
- func (ep ElementalPartitions) GetConfigStorage() string
- func (ep ElementalPartitions) PartitionsByInstallOrder(extraPartitions PartitionList, excludes ...*Partition) PartitionList
- func (ep ElementalPartitions) PartitionsByMountPoint(descending bool, excludes ...*Partition) PartitionList
- func (ep *ElementalPartitions) SetFirmwarePartitions(firmware string, partTable string) error
- type FS
- type HTTPClient
- type Image
- type ImageExtractor
- type ImageSource
- func (i *ImageSource) CustomUnmarshal(data interface{}) (bool, error)
- func (i ImageSource) IsDir() bool
- func (i ImageSource) IsEmpty() bool
- func (i ImageSource) IsFile() bool
- func (i ImageSource) IsImage() bool
- func (i ImageSource) MarshalYAML() (interface{}, error)
- func (i ImageSource) String() string
- func (i *ImageSource) UnmarshalYAML(value *yaml.Node) error
- func (i ImageSource) Value() string
- type ImageState
- type InitSpec
- type InstallSpec
- type InstallState
- type LiveISO
- type Logger
- type LoggerOptions
- type OCIImageExtractor
- type Partition
- type PartitionList
- type PartitionState
- type Platform
- type RealRunner
- func (r RealRunner) CommandExists(command string) bool
- func (r RealRunner) GetLogger() Logger
- func (r RealRunner) InitCmd(command string, args ...string) *exec.Cmd
- func (r RealRunner) Run(command string, args ...string) ([]byte, error)
- func (r RealRunner) RunCmd(cmd *exec.Cmd) ([]byte, error)
- func (r *RealRunner) SetLogger(logger Logger)
- type RealSyscall
- type Repository
- type ResetSpec
- type RunConfig
- type Runner
- type SourceNotFound
- type SyscallInterface
- type UpgradeSpec
Constants ¶
const ( GPT = "gpt" BIOS = "bios" MSDOS = "msdos" EFI = "efi" )
Variables ¶
This section is empty.
Functions ¶
func DebugLevel ¶
func IsDebugLevel ¶
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 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 ¶
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 DiskSpec ¶ added in v1.1.0
type DiskSpec struct { Size uint `yaml:"size,omitempty" mapstructure:"size"` Partitions ElementalPartitions `yaml:"partitions,omitempty" mapstructure:"partitions"` Expandable bool `yaml:"expandable,omitempty" mapstructure:"expandable"` Unprivileged bool `yaml:"unprivileged,omitempty" mapstructure:"unprivileged"` Active Image `yaml:"system,omitempty" mapstructure:"system"` Recovery Image `yaml:"recovery-system,omitempty" mapstructure:"recovery-system"` Passive Image GrubConf string CloudInit []string `yaml:"cloud-init,omitempty" mapstructure:"cloud-init"` GrubDefEntry string `yaml:"grub-entry-name,omitempty" mapstructure:"grub-entry-name"` Type string `yaml:"type,omitempty" mapstructure:"type"` }
func (DiskSpec) GetGrubLabels ¶ added in v1.1.0
func (*DiskSpec) MinDiskSize ¶ added in v1.1.0
minDiskSize counts the minimum size (MB) required for the disk given the partitions setup
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) GetConfigStorage ¶ added in v1.1.0
func (ep ElementalPartitions) GetConfigStorage() string
GetConfigStorage returns the path, usually a mountpoint, of the configuration partition
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 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 ¶
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 ¶
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 ¶
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
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 ¶
NewBufferLogger will return a logger that stores all logs in a buffer, used mainly for testing
func NewNullLogger ¶
func NewNullLogger() Logger
NewNullLogger will return a logger that discards all logs, used mainly for testing
type LoggerOptions ¶
type OCIImageExtractor ¶
type OCIImageExtractor struct{}
func (OCIImageExtractor) ExtractImage ¶
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 ¶
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 ¶
func NewPlatform ¶
func NewPlatformFromArch ¶
func ParsePlatform ¶
func (*Platform) CustomUnmarshal ¶
func (Platform) MarshalYAML ¶
func (*Platform) UnmarshalYAML ¶
type RealRunner ¶
type RealRunner struct {
Logger Logger
}
func (RealRunner) CommandExists ¶
func (r RealRunner) CommandExists(command string) bool
func (RealRunner) GetLogger ¶
func (r RealRunner) GetLogger() Logger
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"` CloudInit []string `yaml:"cloud-init,omitempty" mapstructure:"cloud-init"` 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 ¶
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"` }
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 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 ¶
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