util

package
v0.11.0-alpha Latest Latest
Warning

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

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

Documentation

Overview

Package untar untars a tarball to disk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddElementToString

func AddElementToString(contentToModify string, elementToAdd string, addAfter string, replaceLine bool) (string, bool)

func ComputeFileHash

func ComputeFileHash(filePath string) (string, error)

func ComputeHash

func ComputeHash(reader io.Reader) ([]byte, error)

func ComputeNewHash

func ComputeNewHash(a []byte, hashA []byte, b []byte) ([]byte, error)

Returns new hash if b has changed from a

func CopyFile

func CopyFile(src string, dst string) error

func ExtractTarGz

func ExtractTarGz(body []byte, downloadDir string) error

func ExtractTarGzInsideZip

func ExtractTarGzInsideZip(body []byte, downloadDir string) error

func ExtractZip

func ExtractZip(body []byte, downloadDir string) error

func ExtractZipFileToDir

func ExtractZipFileToDir(zipArchive string, targetDirectory string) error

func GetBytes

func GetBytes(key interface{}) ([]byte, error)

func IsDebug

func IsDebug() bool

func IsRuntimeServerHealthy

func IsRuntimeServerHealthy(serverBaseUrl string, httpClient *http.Client) error

func MakeFileExecutable

func MakeFileExecutable(filepath string) error

func MarshalAndPrintTable

func MarshalAndPrintTable(writer io.Writer, in interface{}) error

func MkDirAllInheritPerm

func MkDirAllInheritPerm(path string) (os.FileMode, error)

func ProcessAFileInZipArchive

func ProcessAFileInZipArchive(zipArchive string, filename string, processFunc ProcessFunc) error

Opens the zip archive, finds a file that matches "filename" and runs "processFunc" on the bytes

func ReplaceEnvVariablesFromPath

func ReplaceEnvVariablesFromPath(filePath string, envVarPrefix string) ([]byte, error)

We have to manually swap out environment variables, as Viper's AutomaticEnv() doesn't work with Unmarshal() and the workarounds do not work for nested structures. See https://github.com/spf13/viper/issues/761

func RunCommand

func RunCommand(cmd *exec.Cmd) error

func SanitizeExtractPath

func SanitizeExtractPath(filePath string, destination string) error

func SaveReaderToFile

func SaveReaderToFile(reader io.Reader, fullFilePath string) error

func Untar

func Untar(r io.Reader, dir string, isGzipped bool) error

Untar reads the gzip-compressed tar file from r and writes it into dir.

func WriteTable

func WriteTable(items []interface{})

func WriteToExistingFile

func WriteToExistingFile(filePath string, contentToWrite []byte) error

Types

type ProcessFunc

type ProcessFunc func([]byte) error

Jump to

Keyboard shortcuts

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