util

package
v0.0.0-...-0000b31 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2017 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backoff

func Backoff(baseDelay, maxDelay time.Duration, retries int) time.Duration

Backoff returns a random value in [0, maxDelay] that increases exponentially with retries, starting from baseDelay. It is the Go equivalent to C++'s //util/time/backoff.cc.

func CheckPodsRunning

func CheckPodsRunning(n string) (ready bool)

CheckPodsRunning return if all pods in a namespace are in "Running" status

func Compare

func Compare(out, model []byte) error

Compare compares two byte slices. It returns an error with a contextual diff if they are not equal.

func CompareFiles

func CompareFiles(outFile, modelFile string) error

CompareFiles compares the content of two files

func CompareToFile

func CompareToFile(out []byte, modelFile string) error

CompareToFile compares a content with a file

func CopyFile

func CopyFile(src, dst string) error

CopyFile create a new file to src based on dst

func CreateNamespace

func CreateNamespace(n string) error

CreateNamespace create a kubernetes namespace

func CreateTempfile

func CreateTempfile(tmpDir, prefix, suffix string) (string, error)

CreateTempfile creates a tempfile string.

func DeleteNamespace

func DeleteNamespace(n string) error

DeleteNamespace delete a kubernetes namespace

func Fill

func Fill(outFile, inFile string, values interface{}) error

Fill complete a template with given values and generate a new output file

func GetIngress

func GetIngress(n string) (string, error)

GetIngress get istio ingress ip

func GetIngressPod

func GetIngressPod(n string) (string, error)

GetIngressPod get istio ingress ip

func GetPodStatus

func GetPodStatus(n, pod string) string

GetPodStatus gets status of a pod from a namespace

func GetPodsName

func GetPodsName(n string) (pods []string)

GetPodsName gets names of all pods in specific namespace and return in a slice

func GetResourcePath

func GetResourcePath(p string) string

GetResourcePath give "path from WORKSPACE", return absolute path at runtime

func HTTPDownload

func HTTPDownload(dst string, src string) error

HTTPDownload download from src(url) and store into dst(local file)

func IsProcessRunning

func IsProcessRunning(p *os.Process) (bool, error)

IsProcessRunning check if a os.Process is running

func IsProcessRunningInt

func IsProcessRunningInt(pid int) (bool, error)

IsProcessRunningInt check if a process of the given pid(int) is running

func IsProcessRunningString

func IsProcessRunningString(pidS string) (bool, error)

IsProcessRunningString check if a process of the given pid(string) is running

func KillProcess

func KillProcess(p *os.Process) (err error)

KillProcess kill a os.Process

func KubeApply

func KubeApply(namespace, yamlFileName string) error

KubeApply kubectl apply from file

func KubeApplyContents

func KubeApplyContents(namespace, yamlContents string) error

KubeApplyContents kubectl apply from contents

func KubeDelete

func KubeDelete(namespace, yamlFileName string) error

KubeDelete kubectl delete from file

func KubeDeleteContents

func KubeDeleteContents(namespace, yamlContents string) error

KubeDeleteContents kubectl apply from contents

func NamespaceDeleted

func NamespaceDeleted(n string) (bool, error)

NamespaceDeleted check if a kubernete namespace is deleted

func ReadJSON

func ReadJSON(jsonPath string, i interface{}) error

ReadJSON creates a struct based on the input json path.

func Record

func Record(command, record string) error

Record run command and record output into a file

func RunBackground

func RunBackground(format string, args ...interface{}) (*os.Process, error)

RunBackground starts a background process and return the Process if succeed

func Shell

func Shell(format string, args ...interface{}) (string, error)

Shell run command on shell and get back output and error if get one

func ShellMuteOutput

func ShellMuteOutput(format string, args ...interface{}) (string, error)

ShellMuteOutput run command on shell and get back output and error if get one without logging the output

func WriteTempfile

func WriteTempfile(tmpDir, prefix, suffix, contents string) (string, error)

WriteTempfile creates a tempfile with the specified contents.

Types

type Break

type Break struct {
	Err error
}

Break the retry loop if the error returned is of this type.

func (Break) Error

func (e Break) Error() string

type LuaTemplate

type LuaTemplate struct {
	TemplatePath string
	Script       string
	Template     interface{}
}

LuaTemplate defines a Lua template or script.

func (*LuaTemplate) Generate

func (l *LuaTemplate) Generate() error

Generate creates the lua scripts in the .Script destination from the .Template.

type Retrier

type Retrier struct {
	// BaseDelay is the minimum delay between retry attempts.
	BaseDelay time.Duration
	// MaxDelay is the maximum delay allowed between retry attempts.
	MaxDelay time.Duration
	// Retries defines number of retry attempts
	Retries int
}

Retrier contains the retry configuration parameters.

func (Retrier) Retry

func (r Retrier) Retry(fn func(retryIndex int) error) (int, error)

Retry calls the given function a number of times, unless it returns a nil or a Break

type Wrk

type Wrk struct {
	BinaryPath string
	TmpDir     string
}

Wrk is a wrapper around wrk.

func (*Wrk) Install

func (w *Wrk) Install() error

Install installs wrk based on the URL provided if the binary is not already installed.

func (*Wrk) Run

func (w *Wrk) Run(format string, args ...interface{}) error

Run runs a wrk command.

Jump to

Keyboard shortcuts

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