helpers

package
v0.0.0-...-7aa9df5 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTmpFile

func CreateTmpFile(contents string) (string, error)

CreateTmpFile creates a temporary file on the disk with the given contents and returns the path to it and an error if something goes wrong.

func DownloadFile

func DownloadFile(url, name, directory string) error

DownloadFile downloads the given url as a file with "name" under "directory"

func ExecToSuccessWithTimeout

func ExecToSuccessWithTimeout(funk ExternalCommandFunc, timeout, interval time.Duration) (string, error)

ExecToSuccessWithTimeout retries the given function until it either succeeds of the timeout is reached. It retries every "interval" duration.

func ExtractFile

func ExtractFile(filePath string) (string, error)

ExtractFile creates a file in a temporary directory on disk from a file embedded with statik. It returns the path to the created file. Caller should make sure the file is deleted after usage (possibly with a defer).

func Kubectl

func Kubectl(command string) (string, error)

Kubectl invoces the `kubectl` command in PATH, running the specified command. It returns the command output and/or error.

func KubectlApplyEmbeddedYaml

func KubectlApplyEmbeddedYaml(yamlPath string) (string, error)

KubectlApplyEmbeddedYaml un-embeds the given yaml file and calls `kubectl apply` on it. It returns the command output and an error (if there is one)

func KubectlDeleteEmbeddedYaml

func KubectlDeleteEmbeddedYaml(yamlPath string, ignoreMissing bool) (string, error)

KubectlDeleteEmbeddedYaml un-embeds the given yaml file and calls `kubectl delete` on it. It returns the command output and an error (if there is one)

func OpenSSLSubjectHash

func OpenSSLSubjectHash(cert string) (string, error)

OpenSSLSubjectHash return the subject_hash of the given CA certificate as returned by this command: openssl x509 -hash -noout https://www.openssl.org/docs/man1.0.2/man1/x509.html TODO: The way this function is implemented, it makes a system call to openssl thus making openssl a dependency. There must be a way to calculate the hash in Go so we don't need openssl.

func RunProc

func RunProc(cmd, dir string, toStdout bool) (string, error)

func RunProcNoErr

func RunProcNoErr(cmd, dir string, toStdout bool) (string, error)

func Untar

func Untar(tarFile, targetDir string) error

Untar takes a path to a tar file and a destination path and untars the file to the destination

func WaitForCommandCompletion

func WaitForCommandCompletion(ui *ui.UI, message string, funk ExternalCommandFunc) (string, error)

Types

type ExternalCommandFunc

type ExternalCommandFunc func() (output string, err error)

Jump to

Keyboard shortcuts

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