util

package
v1.53.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: Apache-2.0 Imports: 25 Imported by: 40

Documentation

Index

Constants

View Source
const (

	// DefaultAlignBlockSize is the alignment size we use to align disk images, its a multiple of all known hardware block sizes 512/4k/8k/32k/64k.
	DefaultAlignBlockSize = 1024 * 1024
)

Variables

This section is empty.

Functions

func AppendZeroWithTruncate added in v1.43.0

func AppendZeroWithTruncate(outFile *os.File, start, length int64) error

AppendZeroWithTruncate resizes the file to append zeroes, meant only for newly-created (empty and zero-length) regular files.

func AppendZeroWithWrite added in v1.43.0

func AppendZeroWithWrite(outFile *os.File, start, length int64) error

AppendZeroWithWrite just does normal file writes to the destination, a slow but reliable fallback option.

func CopyDir added in v1.10.0

func CopyDir(source string, dest string) (err error)

CopyDir copies a dir from one location to another.

func CopyFile added in v1.7.0

func CopyFile(src, dst string) error

CopyFile copies a file from one location to another.

func GetAvailableSpace added in v1.4.0

func GetAvailableSpace(path string) (int64, error)

GetAvailableSpace gets the amount of available space at the path specified.

func GetAvailableSpaceBlock added in v1.8.0

func GetAvailableSpaceBlock(deviceName string) (int64, error)

GetAvailableSpaceBlock gets the amount of available space at the block device path specified.

func GetAvailableSpaceByVolumeMode added in v1.8.0

func GetAvailableSpaceByVolumeMode(volumeMode v1.PersistentVolumeMode) (int64, error)

GetAvailableSpaceByVolumeMode calls another method based on the volumeMode parameter to get the amount of available space at the path specified.

func GetNamespace

func GetNamespace() string

GetNamespace returns the namespace the pod is executing in

func GetRecommendedInstallerLabelsFromCr added in v1.38.0

func GetRecommendedInstallerLabelsFromCr(cr *cdiv1.CDI) map[string]string

GetRecommendedInstallerLabelsFromCr returns the recommended labels to set on CDI resources

func GetUsableSpace added in v1.38.1

func GetUsableSpace(filesystemOverhead float64, availableSpace int64) int64

GetUsableSpace calculates space to use taking file system overhead into account

func LinkFile added in v1.34.3

func LinkFile(source, target string) error

LinkFile symlinks the source to the target

func Md5sum added in v1.41.0

func Md5sum(filePath string) (string, error)

Md5sum calculates the md5sum of a given file

func MergeLabels added in v1.38.0

func MergeLabels(src, dest map[string]string) map[string]string

MergeLabels adds source labels to destination (does not change existing ones)

func MinQuantity added in v1.4.0

func MinQuantity(availableSpace, imageSize *resource.Quantity) resource.Quantity

MinQuantity calculates the minimum of two quantities.

func OpenFileOrBlockDevice added in v1.43.0

func OpenFileOrBlockDevice(fileName string) (*os.File, error)

OpenFileOrBlockDevice opens the destination data file, whether it is a block device or regular file

func ParseEnvVar added in v1.4.0

func ParseEnvVar(envVarName string, decode bool) (string, error)

ParseEnvVar provides a wrapper to attempt to fetch the specified env var

func PunchHole added in v1.43.0

func PunchHole(outFile *os.File, start, length int64) error

PunchHole attempts to zero a range in a file with fallocate, for block devices and pre-allocated files.

func RandAlphaNum

func RandAlphaNum(n int) string

RandAlphaNum provides an implementation to generate a random alpha numeric string of the specified length

func ResolveVolumeMode added in v1.49.0

func ResolveVolumeMode(volumeMode *v1.PersistentVolumeMode) v1.PersistentVolumeMode

ResolveVolumeMode returns the volume mode if set, otherwise defaults to file system mode

func RoundDown added in v1.30.0

func RoundDown(number, multiple int64) int64

RoundDown returns the number rounded down to the nearest multiple.

func RoundUp added in v1.34.0

func RoundUp(number, multiple int64) int64

RoundUp returns the number rounded up to the nearest multiple.

func SetRecommendedLabels added in v1.38.0

func SetRecommendedLabels(obj metav1.Object, installerLabels map[string]string, controllerName string)

SetRecommendedLabels sets the recommended labels on CDI resources (does not get rid of existing ones)

func StreamDataToFile added in v1.9.0

func StreamDataToFile(r io.Reader, fileName string) error

StreamDataToFile provides a function to stream the specified io.Reader to the specified local file

func UnArchiveTar added in v1.5.0

func UnArchiveTar(reader io.Reader, destDir string, arg ...string) error

UnArchiveTar unarchives a tar file and streams its files using the specified io.Reader to the specified destination.

func WriteTerminationMessage added in v1.10.0

func WriteTerminationMessage(message string) error

WriteTerminationMessage writes the passed in message to the default termination message file

func WriteTerminationMessageToFile added in v1.10.0

func WriteTerminationMessageToFile(file, message string) error

WriteTerminationMessageToFile writes the passed in message to the passed in message file

Types

type CountingReader added in v1.4.0

type CountingReader struct {
	Reader  io.ReadCloser
	Current uint64
	Done    bool
}

CountingReader is a reader that keeps track of how much has been read

func (*CountingReader) Close added in v1.4.0

func (r *CountingReader) Close() error

Close closes the stream

func (*CountingReader) Read added in v1.4.0

func (r *CountingReader) Read(p []byte) (n int, err error)

Read reads bytes from the stream and updates the prometheus clone_progress metric according to the progress.

type VddkInfo added in v1.34.3

type VddkInfo struct {
	Version string
	Host    string
}

VddkInfo holds VDDK version and connection information returned by an importer pod

Directories

Path Synopsis
triple
Package triple generates key-certificate pairs for the triple (CA, Server, Client).
Package triple generates key-certificate pairs for the triple (CA, Server, Client).

Jump to

Keyboard shortcuts

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