utils

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 34 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeRecoveryToken added in v0.0.2

func DecodeRecoveryToken(recoverytoken string) []string

func EncodeRecoveryToken added in v0.0.2

func EncodeRecoveryToken(data ...string) string

func Exists

func Exists(path string) bool

func ExtractOCIImage added in v0.0.3

func ExtractOCIImage(img v1.Image, targetDestination string) error

ExtractOCIImage will extract a given targetImage into a given targetDestination

func FindCommand

func FindCommand(def string, options []string) string

func Flavor added in v0.0.2

func Flavor() string

func GetCurrentPlatform added in v0.0.3

func GetCurrentPlatform() string

GetCurrentPlatform returns the current platform in docker style `linux/amd64` for use with image utils

func GetEfiGrubFiles added in v0.0.22

func GetEfiGrubFiles(arch string) []string

GetEfiGrubFiles Return possible paths for the grub.efi Used in enki and agent

func GetEfiShimFiles added in v0.0.22

func GetEfiShimFiles(arch string) []string

GetEfiShimFiles Return possible paths for the shim.efi Used in enki and agent

func GetImage added in v0.0.17

func GetImage(targetImage, targetPlatform string) (v1.Image, error)

GetImage if returns the proper image to pull with transport and auth tries local daemon first and then fallbacks into remote

func GetInit added in v0.0.15

func GetInit() string

GetInit Return the init system used by the OS

func GetInterfaceIP added in v0.0.2

func GetInterfaceIP(in string) string

func GetOCIImageSize added in v0.0.12

func GetOCIImageSize(targetImage, targetPlatform string) (int64, error)

func IsOpenRCBased added in v0.0.2

func IsOpenRCBased() bool

func K3sBin added in v0.0.2

func K3sBin() string

func ListOutput added in v0.0.2

func ListOutput(rels []string, output string) []string

func ListToOutput added in v0.0.2

func ListToOutput(rels []string, output string) []string

func Name added in v0.0.2

func Name() string

func OSRelease

func OSRelease(key string, file ...string) (string, error)

OSRelease finds the value of the specified key in the /etc/os-release file or, if a second argument is passed, on the file specified by the second argument. (optionally file argument is there for testing reasons).

func OnSignal added in v0.0.2

func OnSignal(fn func(), sig ...os.Signal)

func PowerOFF added in v0.0.2

func PowerOFF()

func PrintBanner added in v0.0.2

func PrintBanner(d []byte)

func Prompt added in v0.0.2

func Prompt(t string) (string, error)

func RandStringRunes added in v0.0.2

func RandStringRunes(n int) string

func Reboot added in v0.0.2

func Reboot()

func SH

func SH(c string) (string, error)

func SHInDir

func SHInDir(c, dir string, envs ...string) (string, error)

func SetEnv added in v0.0.2

func SetEnv(env []string)

func Shell added in v0.0.2

func Shell() *exec.Cmd

func ShellSTDIN added in v0.0.2

func ShellSTDIN(s, c string) (string, error)

func SystemdBootConfReader added in v0.0.25

func SystemdBootConfReader(filePath string) (map[string]string, error)

SystemdBootConfReader reads a systemd-boot conf file and returns a map with the key/value pairs

func UUID

func UUID() string

UUID TODO: move this into a machine submodule

func Version added in v0.0.2

func Version() string

func WriteEnv added in v0.0.2

func WriteEnv(envFile string, config map[string]string) error

Types

type CleanJob added in v0.0.10

type CleanJob func() error

type CleanStack added in v0.0.10

type CleanStack struct {
	// contains filtered or unexported fields
}

CleanStack is a basic LIFO stack that resizes as needed.

func NewCleanStack added in v0.0.10

func NewCleanStack() *CleanStack

NewCleanStack returns a new stack. It's used to push jobs into it that need to be executed in order, like unmounting disks or removing dirs, and it will run those jobs in the order they were pushed into it to maintain order So you can create a dir, push its removal into the stack, mount something into that dir and push its unmounting into the stack and when cleanup is triggered it will first unmount and then remove the dir Usually its setup inside a function with a defer immediately so it auto cleans if you return from anywhere in the function That way you don't need to track on each return what needs to be cleaned and whatnot cleanup := utils.NewCleanStack() defer func() { err = cleanup.Cleanup(err) }()

func (*CleanStack) Cleanup added in v0.0.10

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 added in v0.0.10

func (clean *CleanStack) Pop() CleanJob

Pop removes and returns a node from the stack in last to first order.

func (*CleanStack) Push added in v0.0.10

func (clean *CleanStack) Push(job CleanJob)

Push adds a node to the stack

type KeyNotFoundErr added in v0.0.20

type KeyNotFoundErr struct {
	Err error
}

func (KeyNotFoundErr) Error added in v0.0.20

func (err KeyNotFoundErr) Error() string

Jump to

Keyboard shortcuts

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