util

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolToPtr

func BoolToPtr(b bool) *bool

func CreateSSHAuthorizedKey

func CreateSSHAuthorizedKey(tmpd string) ([]byte, string, error)

CreateSSHAuthorizedKey generates a public key to sanity check that Ignition accepts it.

func DownloadImageAndDecompress

func DownloadImageAndDecompress(url, compressedDest string, skipSignature bool) (string, error)

Note this is a no-op if the decompressed dest already exists.

func GetLocalFastBuildQemu

func GetLocalFastBuildQemu() (string, error)

GetLocalFastBuildQemu finds content written by `cosa build-fast`

func IntToPtr

func IntToPtr(i int) *int

func IsCosaRoot

func IsCosaRoot(root string) (bool, error)

func LogFrom

func LogFrom(l capnslog.LogLevel, r io.Reader)

LogFrom reads lines from reader r and sends them to logger l.

func ParseDiskSpec

func ParseDiskSpec(spec string) (int64, map[string]string, error)

ParseDiskSpec converts a disk specification into a Disk. The format is: <size>[:<opt1>,<opt2>,...], like ["5G:channel=nvme"]

func PathExists

func PathExists(path string) (bool, error)

func RequireCosaRoot

func RequireCosaRoot(root string) error

func Retry

func Retry(attempts int, delay time.Duration, f func() error) error

Retry calls function f until it has been called attemps times, or succeeds. Retry delays for delay between calls of f. If f does not succeed after attempts calls, the error from the last call is returned.

func RetryConditional

func RetryConditional(attempts int, delay time.Duration, shouldRetry func(err error) bool, f func() error) error

RetryConditional calls function f until it has been called attemps times, or succeeds. Retry delays for delay between calls of f. If f does not succeed after attempts calls, the error from the last call is returned. If shouldRetry returns false on the error generated, RetryConditional stops immediately and returns the error

func RetryUntilTimeout

func RetryUntilTimeout(timeout, delay time.Duration, f func() error) error

RetryUntilTimeout calls function f until it succeeds or until the given timeout is reached. It will wait a given amount of time between each try based on the given delay.

func RunCmdTimeout

func RunCmdTimeout(timeout time.Duration, cmd string, args ...string) error

RunCmdTimeout runs a command but returns an error if it doesn't complete before the given duration.

func StrToPtr

func StrToPtr(s string) *string

func TargetDistro

func TargetDistro(build *builds.Build) (string, error)

TargetDistro returns the distribution of a cosa build

func TargetDistroFromName

func TargetDistroFromName(artifact string) string

TargetDistroFromName returns the distribution given the path to an artifact (usually a disk image).

func WaitUntilReady

func WaitUntilReady(timeout, delay time.Duration, checkFunction func() (bool, error)) error

Types

type Endian

type Endian int

Endianness of the platform - big or little

const (
	LITTLE Endian = iota // little endian
	BIG                  // big endian
)
var HostEndianness Endian

type ImageInfo

type ImageInfo struct {
	Format      string `json:"format"`
	VirtualSize uint64 `json:"virtual-size"`
}

func GetImageInfo

func GetImageInfo(path string) (*ImageInfo, error)

type LocalBuild

type LocalBuild struct {
	Dir  string
	Arch string
	Meta *cosa.Build
}

Build is a parsed coreos-assembler build

func GetLatestLocalBuild

func GetLatestLocalBuild(root, arch string) (*LocalBuild, error)

func GetLocalBuild

func GetLocalBuild(root, buildid, arch string) (*LocalBuild, error)

Jump to

Keyboard shortcuts

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