Documentation ¶
Overview ¶
Package utils implements helper functions
Index ¶
- Variables
- func CopyDir(src, dest string) error
- func CopyFile(src, dest string) error
- func ExecuteWithRetry(retries int, cb func(try int, prevErr error) error) error
- func FileExists(filename string) bool
- func FindFileInTar(ctx context.Context, tarFilename string, path string, ...) error
- func IsTarFile(filename string) (bool, error)
- func RelocateImageURL(url string, prefix string, includeIndentifier bool) (string, error)
- func SafeWriteFile(filename string, data []byte, perm os.FileMode) error
- func Tar(sourceDir string, filename string, cfg TarConfig) error
- func TarContext(parentCtx context.Context, sourceDir string, filename string, cfg TarConfig) error
- func TruncateStringWithEllipsis(text string, maxLength int) string
- func Untar(filename string, outputDir string, cfg TarConfig) error
- func UntarContext(ctx context.Context, filename string, outputDir string, cfg TarConfig) error
- func WalkTarFile(ctx context.Context, filename string, ...) error
- func YamlFileSet(file string, values map[string]string) error
- func YamlSet(data []byte, values map[string]string) ([]byte, error)
- type TarConfig
Constants ¶
This section is empty.
Variables ¶
var ErrEndTarWalk = errors.New("end walking tar contents")
ErrEndTarWalk allows early stopping inspecting the tar file
var MaxDecompressionSize int64 = 8 * 1024 * 1024 * 1024
MaxDecompressionSize established a high enough maximum tar size to decompres to prevent decompression bombs (8GB)
Functions ¶
func ExecuteWithRetry ¶
ExecuteWithRetry executes a function retrying until it succeeds or the number of retries is reached
func FindFileInTar ¶
func FindFileInTar(ctx context.Context, tarFilename string, path string, operation func(tr *tar.Reader) error, cfg TarConfig) error
FindFileInTar finds path in the tarFilename contents and processes it via the provided operation
func RelocateImageURL ¶
RelocateImageURL rewrites the provided image url by replacing its prefix
func SafeWriteFile ¶
SafeWriteFile writes data into the specified filename by first creating it, and then renaming to the final destination to minimize breaking the file
func TarContext ¶
TarContext compresses the provided sourceDir directory into the .tar.gz specified in filename, adding prefix to the added files.
func TruncateStringWithEllipsis ¶
TruncateStringWithEllipsis returns a truncated version of text
func Untar ¶
Untar decompresses the provided filename into the outputDir Simplified implementation taken from: golang.org/x/build/internal/untar (BSD license)
func UntarContext ¶
UntarContext decompresses the provided filename into the outputDir Simplified implementation taken from: golang.org/x/build/internal/untar (BSD license)
func WalkTarFile ¶
func WalkTarFile(ctx context.Context, filename string, operation func(tr *tar.Reader, header *tar.Header) error) error
WalkTarFile iterates over the list of tar entries and applies the provided operation
func YamlFileSet ¶
YamlFileSet sets the list of key-value specified in values in the YAML file. The keys are in jsonpath format