Documentation
¶
Index ¶
- Constants
- func CalcFileChecksum(fs v1.FS, fileName string) (string, error)
- func ChrootedCallback(cfg *agentConfig.Config, path string, bindMounts map[string]string, ...) error
- func CommandExists(command string) bool
- func ConcatFiles(fs v1.FS, sources []string, target string) (err error)
- func CopyFile(fs v1.FS, source string, target string) (err error)
- func CosignVerify(fs v1.FS, runner v1.Runner, image string, publicKey string, debug bool) (string, error)
- func CreateDirStructure(fs v1.FS, target string) error
- func CreateSquashFS(runner v1.Runner, logger v1.Logger, source string, destination string, ...) error
- func FindCommand(defaultPath string, options []string) string
- func FindFileWithPrefix(fs v1.FS, path string, prefixes ...string) (string, error)
- func GetDeviceByLabel(runner v1.Runner, label string, attempts int) (string, error)
- func GetFullDeviceByLabel(runner v1.Runner, label string, attempts int) (*v1.Partition, error)
- func GetSource(config *agentConfig.Config, source string, destination string) error
- func GetTempDir(config *agentConfig.Config, suffix string) string
- func IsHTTPURI(uri string) (bool, error)
- func IsLocalURI(uri string) (bool, error)
- func IsMounted(config *agentConfig.Config, part *v1.Partition) (bool, error)
- func IsUki() bool
- func LoadEnvFile(fs v1.FS, file string) (map[string]string, error)
- func Reboot(runner v1.Runner, delay time.Duration) error
- func RunStage(cfg *agentConfig.Config, stage string) error
- func Shutdown(runner v1.Runner, delay time.Duration) error
- func SyncData(log v1.Logger, runner v1.Runner, fs v1.FS, source string, target string, ...) error
- func UkiBootMode() state.Boot
- func ValidContainerReference(ref string) bool
- func ValidTaggedContainerReference(ref string) bool
- type Chroot
- type CleanJob
- type CleanStack
- type Grub
Constants ¶
const ( UkiHDD state.Boot = "uki_boot_mode" UkiRemovableMedia state.Boot = "uki_install_mode" )
Variables ¶
This section is empty.
Functions ¶
func CalcFileChecksum ¶
CalcFileChecksum opens the given file and returns the sha256 checksum of it.
func ChrootedCallback ¶
func ChrootedCallback(cfg *agentConfig.Config, path string, bindMounts map[string]string, callback func() error) error
ChrootedCallback runs the given callback in a chroot environment
func CommandExists ¶
func ConcatFiles ¶
ConcatFiles Copies source files to target file using Fs interface. Source files are concatenated into target file in the given order. If target is a directory source is copied into that directory using 1st source name file.
func CopyFile ¶
CopyFile Copies source file to target file using Fs interface. If target is directory source is copied into that directory using source name file.
func CosignVerify ¶
func CosignVerify(fs v1.FS, runner v1.Runner, image string, publicKey string, debug bool) (string, error)
CosignVerify runs a cosign validation for the give image and given public key. If no key is provided then it attempts a keyless validation (experimental feature).
func CreateDirStructure ¶
Copies source file to target file using Fs interface
func CreateSquashFS ¶
func CreateSquashFS(runner v1.Runner, logger v1.Logger, source string, destination string, options []string) error
CreateSquashFS creates a squash file at destination from a source, with options TODO: Check validity of source maybe?
func FindCommand ¶
FindCommand will search for the command(s) in the options given to find the current command If it cant find it returns the default value give. Useful for the same binaries with different names across OS
func FindFileWithPrefix ¶
FindFileWithPrefix looks for a file in the given path matching one of the given prefixes. Returns the found file path including the given path. It does not check subfolders recusively
func GetDeviceByLabel ¶
GetDeviceByLabel will try to return the device that matches the given label. attempts value sets the number of attempts to find the device, it waits a second between attempts.
func GetFullDeviceByLabel ¶
GetFullDeviceByLabel works like GetDeviceByLabel, but it will try to get as much info as possible from the existing partition and return a v1.Partition object
func GetSource ¶
func GetSource(config *agentConfig.Config, source string, destination string) error
GetSource copies given source to destination, if source is a local path it simply copies files, if source is a remote URL it tries to download URL to destination.
func GetTempDir ¶
func GetTempDir(config *agentConfig.Config, suffix string) string
GetTempDir returns the dir for storing related temporal files It will respect TMPDIR and use that if exists, fallback to try the persistent partition if its mounted and finally the default /tmp/ dir suffix is what is appended to the dir name elemental-suffix. If empty it will randomly generate a number
func IsHTTPURI ¶
IsHTTPURI returns true if the uri has "http" or "https" scheme, returns false otherwise. Error is not nil only if the url can't be parsed.
func IsLocalURI ¶
IsLocalURI returns true if the uri has "file" scheme or no scheme and URI is not prefixed with a domain (container registry style). Returns false otherwise. Error is not nil only if the url can't be parsed.
func IsUki ¶ added in v2.6.3
func IsUki() bool
IsUki returns true if the system is running in UKI mode. Checks the cmdline as UKI artifacts have the rd.immucore.uki flag
func LoadEnvFile ¶
LoadEnvFile will try to parse the file given and return a map with the kye/values
func SyncData ¶
func SyncData(log v1.Logger, runner v1.Runner, fs v1.FS, source string, target string, excludes ...string) error
SyncData rsync's source folder contents to a target folder content, both are expected to exist beforehand.
func UkiBootMode ¶ added in v2.6.3
UkiBootMode will return where the system is running from, either HDD or RemovableMedia HDD means we are booting from an already installed system RemovableMedia means we are booting from a live media like a CD or USB
func ValidContainerReference ¶
ValidContainerReferece returns true if the given string matches a container registry reference, false otherwise
func ValidTaggedContainerReference ¶
ValidTaggedContainerReferece returns true if the given string matches a container registry reference including a tag, false otherwise.
Types ¶
type Chroot ¶
type Chroot struct {
// contains filtered or unexported fields
}
Chroot represents the struct that will allow us to run commands inside a given chroot
func (*Chroot) Prepare ¶
Prepare will mount the defaultMounts as bind mounts, to be ready when we run chroot
func (*Chroot) RunCallback ¶
RunCallback runs the given callback in a chroot environment
func (*Chroot) SetExtraMounts ¶
Sets additional bind mounts for the chroot enviornment. They are represented in a map where the key is the path outside the chroot and the value is the path inside the chroot.
type CleanStack ¶
type CleanStack struct {
// contains filtered or unexported fields
}
Stack is a basic LIFO stack that resizes as needed.
func (*CleanStack) Cleanup ¶
func (clean *CleanStack) Cleanup(err error) error
Cleanup runs the whole cleanup stack. In case of error it runs all jobs and returns the first error occurrence.
func (*CleanStack) Pop ¶
func (clean *CleanStack) Pop() CleanJob
Pop removes and returns a node from the stack in last to first order.
type Grub ¶
type Grub struct {
// contains filtered or unexported fields
}
Grub is the struct that will allow us to install grub to the target device
func NewGrub ¶
func NewGrub(config *agentConfig.Config) *Grub