Documentation ¶
Index ¶
- Constants
- func AddBootAssessment(fs v1.FS, artifactDir string, logger sdkTypes.KairosLogger) error
- func CalcFileChecksum(fs v1.FS, fileName string) (string, error)
- func CheckFailedInstallation(stateFile string) (bool, 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) (string, error)
- func CreateDirStructure(fs v1.FS, target string) error
- func CreateSquashFS(runner v1.Runner, logger sdkTypes.KairosLogger, source string, ...) error
- func FindCommand(defaultPath string, options []string) string
- func FindFileWithPrefix(fs v1.FS, path string, prefixes ...string) (string, error)
- func GetDeviceByLabel(config *agentConfig.Config, label string, attempts int) (string, 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 *types.Partition) (bool, error)
- func IsUki() bool
- func IsUkiWithFs(fs v1.FS) bool
- func LoadEnvFile(fs v1.FS, file string) (map[string]string, error)
- func ReadAssessmentFromEntry(fs v1.FS, entry string, logger sdkTypes.KairosLogger) (string, error)
- func ReadPersistentVariables(grubEnvFile string, fs v1.FS) (map[string]string, error)
- func Reboot(runner v1.Runner, delay time.Duration) error
- func RunStage(cfg *agentConfig.Config, stage string) error
- func RunStageAnalyze(cfg *agentConfig.Config, stage string) error
- func SetPersistentVariables(grubEnvFile string, vars map[string]string, fs v1.FS) error
- func Shutdown(runner v1.Runner, delay time.Duration) error
- func SyncData(log sdkTypes.KairosLogger, runner v1.Runner, fs v1.FS, source string, ...) error
- func SystemdBootConfReader(vfs v1.FS, filePath string) (map[string]string, error)
- func SystemdBootConfWriter(fs v1.FS, filePath string, conf map[string]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 AddBootAssessment ¶ added in v2.16.0
AddBootAssessment adds boot assessment to files by appending +3 to the name Only for files that dont have it already as those are the ones upgraded Existing files that have a boot assessment will be left as is This should be called during install, upgrade and reset Mainly everything that updates the config files to point to a new artifact we need to reset the boot assessment as its a new artifact that needs to be assessed
func CalcFileChecksum ¶
CalcFileChecksum opens the given file and returns the sha256 checksum of it.
func CheckFailedInstallation ¶ added in v2.13.4
CheckFailedInstallation checks if the state file if present, and if it is, it will return true and the error with the file content indicating why we should abort the installation
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. TODO: Log errors, return errors, whatever but dont ignore them
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 ¶
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 sdkTypes.KairosLogger, 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 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 IsUkiWithFs ¶ added in v2.7.13
IsUkiWithFs checks if the system is running in UKI mode by checking the kernel command line for the rd.immucore.uki flag Uses a v1.Fs interface to allow for testing
func LoadEnvFile ¶
LoadEnvFile will try to parse the file given and return a map with the kye/values
func ReadAssessmentFromEntry ¶ added in v2.16.0
func ReadPersistentVariables ¶ added in v2.14.0
ReadPersistentVariables will read a grub env file and parse the values
func RunStageAnalyze ¶ added in v2.14.2
func RunStageAnalyze(cfg *agentConfig.Config, stage string) error
RunstageAnalyze
func SetPersistentVariables ¶ added in v2.14.0
SetPersistentVariables sets the given vars into the given grubEnvFile for grub to read them
func SyncData ¶
func SyncData(log sdkTypes.KairosLogger, 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 SystemdBootConfReader ¶ added in v2.7.6
SystemdBootConfReader reads a systemd-boot conf file and returns a map with the key/value pairs TODO: Move this to the sdk with the FS interface
func SystemdBootConfWriter ¶ added in v2.7.13
SystemdBootConfWriter writes a map to a systemd-boot conf file TODO: Move this to the sdk with the FS interface
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.