utils

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcFileChecksum

func CalcFileChecksum(fs v1.FS, fileName string) (string, error)

CalcFileChecksum opens the given file and returns the sha256 checksum of it.

func ConcatFiles

func ConcatFiles(fs v1.FS, sources []string, target string) (err error)

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

func CopyFile(fs v1.FS, source string, target string) (err error)

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 CreateDirStructure

func CreateDirStructure(fs v1.FS, target string) error

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 CreateTar

func CreateTar(log sdkTypes.KairosLogger, srctar, dstimageTar, imagename, architecture, OS string) error

CreateTar a imagetarball from a standard tarball

func DirSize

func DirSize(fs v1.FS, path string) (int64, error)

DirSize returns the accumulated size of all files in folder

func Exists

func Exists(fs v1.FS, path string) (bool, error)

Check if a file or directory exists.

func GolangArchToArch

func GolangArchToArch(arch string) (string, error)

func IsAmd64

func IsAmd64(arch string) bool

func IsArm64

func IsArm64(arch string) bool

func IsDir

func IsDir(fs v1.FS, path string) (bool, error)

IsDir check if the path is a dir

func MkdirAll

func MkdirAll(fs v1.FS, name string, mode os.FileMode) (err error)

MkdirAll directory and all parents if not existing

func NameFromCmdline

func NameFromCmdline(basename, cmdline string) string

NameFromCmdline returns the name of the efi/conf file based on the cmdline we want to have at least 1 efi file that its the default, that is the one we ship with the iso/media/whatever install medium that one has the default cmdline + the install cmdline For that one, we use it as the BASE one, configs will only trigger for that install stanza if we are on install media so we dont have to worry about it, but we want to provide a clean name for it so in that case we dont add anything to the efi name/conf name/cmdline inside the config For the other ones, we add the cmdline to the efi name and the cmdline to the conf file so you get - norole.efi - norole.conf - norole_interactive-install.efi - norole_interactive-install.conf This is mostly for convenience in generating the names as the real data is stored in the config file but it can easily be used to identify the efi file and the conf file.

func Tar

func Tar(src string, writers ...io.Writer) error

Tar takes a source and variable writers and walks 'source' writing each file found to the tar writer; the purpose for accepting multiple writers is to allow for multiple outputs (for example a file, or md5 hash)

func TempDir

func TempDir(fs v1.FS, dir, prefix string) (name string, err error)

TempDir creates a temp file in the virtual fs Took from afero.FS code and adapted

Types

type BootEntry

type BootEntry struct {
	FileName string
	Cmdline  string
	Title    string
}

func GetUkiCmdline

func GetUkiCmdline() []BootEntry

GetUkiCmdline returns the cmdline to be used for the kernel. The cmdline can be overridden by the user using the cmdline flag. For each cmdline passed, we generate a uki file with that cmdline extend-cmdline will just extend the default cmdline so we only create one efi file extra-cmdline will create a new efi file for each cmdline passed

func GetUkiSingleCmdlines

func GetUkiSingleCmdlines(logger sdkTypes.KairosLogger) []BootEntry

GetUkiSingleCmdlines returns the single-efi-cmdline as passed by the user.

Jump to

Keyboard shortcuts

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