Documentation ¶
Index ¶
- func BackupAndCopyResolvConf(chroot string) error
- func BackupReplace(target string, content string) (func(error) error, error)
- func BoolPtr(b bool) *bool
- func CalculateSHA256(fileName string) (string, error)
- func CaptureStd(toCap **os.File) (io.Reader, func(), error)
- func CheckEmptyFields(Interface interface{}, result *gojsonschema.Result, schema *jsonschema.Schema) error
- func CheckTags(searchStruct interface{}, tag string) (string, error)
- func CopyBlob(ddArgs []string) error
- func CreateTarArchive(src, dest, compression string, debug bool) error
- func Du(path string) (quantity.Size, error)
- func ExtractTarArchive(src, dest string, debug bool) error
- func InitCommonOpts() (*commands.CommonOpts, *commands.StateMachineOpts)
- func IsRootfsStructure(s *gadget.VolumeStructure) bool
- func IsSystemBootStructure(s *gadget.VolumeStructure) bool
- func IsSystemDataStructure(s *gadget.VolumeStructure) bool
- func IsSystemSeedStructure(s *gadget.VolumeStructure) bool
- func RestoreResolvConf(chroot string) error
- func RunCmd(cmd *exec.Cmd, debug bool) error
- func RunCmds(cmds []*exec.Cmd, debug bool) error
- func RunScript(hookScript string) error
- func SafeQuantitySubtraction(orig, subtract quantity.Size) quantity.Size
- func SetCommandOutput(cmd *exec.Cmd, liveOutput bool) (cmdOutput *bytes.Buffer)
- func SetDefaults(needsDefaults interface{}) error
- func ShouldSkipStructure(structure *gadget.VolumeStructure, isSeeded bool) bool
- func SliceHasElement(haystack []string, needle string) bool
- type Asserter
- type MissingFieldError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BackupAndCopyResolvConf ¶
BackupAndCopyResolvConf creates a backup of /etc/resolv.conf in a chroot and copies the contents from the host system into the chroot
func BackupReplace ¶
BackupReplace backup the target file and replace it with the given content Returns the restore function.
func CalculateSHA256 ¶
CalculateSHA256 calculates the SHA256 sum of the file provided as an argument
func CaptureStd ¶
CaptureStd returns an io.Reader to read what was printed, and teardown
func CheckEmptyFields ¶
func CheckEmptyFields(Interface interface{}, result *gojsonschema.Result, schema *jsonschema.Schema) error
CheckEmptyFields iterates through the image definition struct and checks for fields that are present but return IsZero == true. TODO: I've created a PR upstream in xeipuuv/gojsonschema https://github.com/xeipuuv/gojsonschema/pull/352 if it gets merged this can be deleted
func CheckTags ¶
CheckTags iterates through the keys in a struct and looks for a value passed in as a parameter. It returns the yaml name of the key and an error. Currently only boolean values for the tags are supported
func CreateTarArchive ¶
CreateTarArchive places all of the files from a source directory into a tar. Currently supported are uncompressed tar archives and the following compression types: gzip, xz bzip2, zstd
func ExtractTarArchive ¶
ExtractTarArchive extracts all the files from a tar. Currently supported are uncompressed tar archives and the following compression types: zip, gzip, xz bzip2, zstd
func InitCommonOpts ¶
func InitCommonOpts() (*commands.CommonOpts, *commands.StateMachineOpts)
InitCommonOpts initializes default common options for state machines. This is used for test scenarios to avoid nil pointer dereferences
func IsRootfsStructure ¶
func IsRootfsStructure(s *gadget.VolumeStructure) bool
IsRootfsStructure determines if the given structure is the one associated to the rootfs
func IsSystemBootStructure ¶
func IsSystemBootStructure(s *gadget.VolumeStructure) bool
IsSystemBootStructure determines if the given structure is the system-boot one
func IsSystemDataStructure ¶
func IsSystemDataStructure(s *gadget.VolumeStructure) bool
IsSystemDataStructure determines if the given structure is the system-data one
func IsSystemSeedStructure ¶
func IsSystemSeedStructure(s *gadget.VolumeStructure) bool
IsSystemSeedStructure determines if the given structure is the system-seed one
func RestoreResolvConf ¶
RestoreResolvConf restores the resolv.conf in the chroot from the version that was backed up by BackupAndCopyResolvConf
func SafeQuantitySubtraction ¶
SafeQuantitySubtraction subtracts quantities while checking for integer underflow
func SetCommandOutput ¶
SetCommandOutput sets the output of a command to either use a multiwriter or behave as a normal command and store the output in a buffer
func SetDefaults ¶
func SetDefaults(needsDefaults interface{}) error
SetDefaults iterates through the keys in a struct and sets default values if one is specified with a struct tag of "default". Currently only default values of strings, slice of strings, and bools are supported
func ShouldSkipStructure ¶
func ShouldSkipStructure(structure *gadget.VolumeStructure, isSeeded bool) bool
ShouldSkipStructure returns whether a structure should be skipped during certain processing
func SliceHasElement ¶
SliceHasElement searches for a string in a slice of strings and returns whether it is found
Types ¶
type Asserter ¶
Asserter for testing purposes
func (*Asserter) AssertEqual ¶
AssertEqual asserts that two objects are equal using go-cmp
func (*Asserter) AssertErrContains ¶
AssertErrContains asserts that an error is non-nil, and that the error message string contains a sub-string that is passed in
func (*Asserter) AssertErrNil ¶
AssertErrNil asserts that an error is nil. If the boolean fatal is true, it ends the test on a non-nil error. Otherwise, it lets the test continue running but marks it as failed
type MissingFieldError ¶
type MissingFieldError struct {
gojsonschema.ResultErrorFields
}
MissingFieldError is used when the fields exist but are the zero value for their type