utils

package
v0.19.4 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Overview

Forked from https://github.com/sigstore/cosign/blob/v1.7.1/pkg/sget/sget.go

Index

Constants

View Source
const SGETProtocol = "sget://"

Variables

View Source
var TempPathPrefix = "zarf-"

Functions

func ByteFormat

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

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, cosignKeyPath string)

func ExecCommandWithContext added in v0.18.0

func ExecCommandWithContext(ctx context.Context, showLogs bool, commandName string, args ...string) (string, string, error)

nolint

func Fetch

func Fetch(url string) io.ReadCloser

func GetFinalExecutablePath added in v0.19.2

func GetFinalExecutablePath() (string, error)

GetFinalExecutablePath returns the absolute path to the zarf executable, following any symlinks along the way

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 GetLatestReleaseTag added in v0.19.3

func GetLatestReleaseTag(project string) (string, error)

GetLatestReleaseTag returns the latest release tag for the given github project

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

func ReadYaml(path string, destConfig any) 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

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

func RunPreflightChecks

func RunPreflightChecks()

func Sget added in v0.18.0

func Sget(image, key string, out io.Writer, ctx context.Context) error

Sget performs a cosign signature verification on a given image using the specified public key.

func SwapHost

func SwapHost(src string, targetHost string) string

SwapHost Perform base url replacment without the docker libs

func ValidHostname

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

func WriteYaml(path string, srcConfig any, perm fs.FileMode) error

Types

type WriteCounter

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

func NewWriteCounter

func NewWriteCounter(url string, total int) *WriteCounter

func (*WriteCounter) Write

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