utils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CancelOnInterrupt added in v0.3.0

func CancelOnInterrupt(ctx context.Context) context.Context

CancelOnInterrupt creates a context and calls the context cancel function when an interrupt signal is caught

func CreateTempFile added in v0.3.0

func CreateTempFile(t *testing.T, data string) string

CreateTempFile creates a temporary file for tests with data as content.

func IsMaxRetries

func IsMaxRetries(err error) bool

IsMaxRetries checks whether the error is due to hitting the maximum number of retries or not.

func KillContainer added in v0.2.0

func KillContainer(containerName string) error

KillContainer stops and removes specified container.

func OrStrings added in v0.2.0

func OrStrings(strs ...string) string

OrStrings returns the first non empty string in its arguments

func PullImage added in v0.2.0

func PullImage(imageName string) error

PullImage pulls an image from docker hub if image is not available or not up to date.

func Retry

func Retry(fn Func, maxRetries int) error

Retry keeps trying the function until the second argument returns false, or no error is returned.

func RunContainer added in v0.2.0

func RunContainer(containerName string, imageName string, exposedPorts nat.PortSet, portBindings nat.PortMap) error

RunContainer reproduces docker run command.

func RunContainerWithEnv added in v0.3.0

func RunContainerWithEnv(containerName string, imageName string, envVariables []string, exposedPorts nat.PortSet, portBindings nat.PortMap) error

RunContainerWithEnv reproduces docker run command.

Types

type Func

type Func func(attempt int) (retry bool, err error)

Func represents functions that can be retried.

Jump to

Keyboard shortcuts

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