utils

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: Apache-2.0, Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TempPathPrefix = "zarf-"

Functions

func ByteFormat added in v0.15.0

func ByteFormat(inputNum float64, precision int) string

func ColorPrintYAML

func ColorPrintYAML(text string)

func CreateDirectory

func CreateDirectory(path string, mode os.FileMode) error

CreateDirectory creates a directory for the given path and file mode

func CreateFilePath

func CreateFilePath(destination string) error

func CreatePathAndCopy

func CreatePathAndCopy(source string, destination string)

func DockerLogin added in v0.15.0

func DockerLogin(serverAddress string, user string, password string) error

DockerLogin adds the given creds to the user's Docker config, usually located at $HOME/.docker/config.yaml. It does not try to connect to the given registry, it just simply adds another entry to the config file. This function was mostly adapted from https://github.com/google/go-containerregistry/blob/5c9c442d5d68cd96787559ebf6e984c7eb084913/cmd/crane/cmd/auth.go

func DownloadToFile

func DownloadToFile(url string, target string)

func ExecCommand

func ExecCommand(showLogs bool, envVariables []string, commandName string, args ...string) (string, error)

func Fetch

func Fetch(url string) io.ReadCloser

func GetHtpasswdString

func GetHtpasswdString(username string, password string) (string, error)

GetHtpasswdString converts a username and password to a properly formatted and hashed format for `htpasswd`

func GetSha256Sum

func GetSha256Sum(path string) (string, error)

GetSha256Sum returns the computed SHA256 Sum of a given file

func InvalidPath

func InvalidPath(path string) bool

InvalidPath checks if the given path exists

func IsRHEL

func IsRHEL() bool

func IsUrl

func IsUrl(source string) bool

func IsValidHostName

func IsValidHostName() bool

func ListDirectories

func ListDirectories(directory string) ([]string, error)

func MakeTempDir

func MakeTempDir() (string, error)

func RandomString

func RandomString(length int) string

func ReadYaml added in v0.14.0

func ReadYaml(path string, destConfig interface{}) error

func RecursiveFileList

func RecursiveFileList(root string, pattern *regexp.Regexp) []string

RecursiveFileList walks a path with an optional regex pattern and returns a slice of file paths

func ReplaceText

func ReplaceText(path string, old string, new string)

func RoundUp added in v0.15.0

func RoundUp(input float64, places int) (newVal float64)

func RunPreflightChecks

func RunPreflightChecks()

func SwapHost added in v0.15.0

func SwapHost(src string, targetHost string) string

SwapHost Perform base url replacment without the docker libs

func ValidHostname added in v0.14.0

func ValidHostname(hostname string) bool

func ValidateSha256Sum

func ValidateSha256Sum(expectedChecksum string, path string)

func VerifyBinary

func VerifyBinary(binary string) bool

VerifyBinary returns true if binary is available

func WriteFile

func WriteFile(path string, data []byte) error

func WriteYaml added in v0.14.0

func WriteYaml(path string, srcConfig interface{}, perm fs.FileMode) error

Types

type WriteCounter added in v0.15.0

type WriteCounter struct {
	Total int
	// contains filtered or unexported fields
}

func NewWriteCounter added in v0.15.0

func NewWriteCounter(url string, total int) *WriteCounter

func (*WriteCounter) Write added in v0.15.0

func (wc *WriteCounter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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