helpers

package
v5.9.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2019 License: Apache-2.0 Imports: 22 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(dest string, src string) error

CopyFile copies a file, overwriting the destination if it exists.

func CopyFileNoOverwrite

func CopyFileNoOverwrite(dest string, src string) error

CopyFileNoOverwrite copies a file only if the destination file does not exist.

func CreateCertTemplate

func CreateCertTemplate() *x509.Certificate

CreateCertTemplate will construct the template for needed openssl metadata instead of using an attributes.cnf file

func CreateKeyPair

func CreateKeyPair() (*rsa.PrivateKey, error)

CreateKeyPair constructs an RSA keypair in memory

func DownloadFile

func DownloadFile(url string, filePath string) error

DownloadFile will download a file from the passed URL and write that file to the supplied file path. If the path is left empty, the file name will be inferred from the source and written to PWD.

func DownloadFileAsString

func DownloadFileAsString(url string) (string, error)

DownloadFileAsString will download a file from the passed URL and return the result as a string.

func GenerateCertificate

func GenerateCertificate(cert string, template, parent *x509.Certificate, pubkey interface{}, privkey interface{}) error

GenerateCertificate will create the private signing key and public certificate for clients to use and writes them to disk

func Git

func Git(args ...string) error

Git runs git with arguments and returns in case of failure. IMPORTANT: the 'args' passed to this function _must_ be validated, as to avoid cases where input is received from a third party source. Such inputs could be something the likes of 'status; rm -rf .*' and need to be escaped or avoided properly.

func ListVisibleFiles

func ListVisibleFiles(dirname string) ([]string, error)

ListVisibleFiles reads the directory named by dirname and returns a sorted list of names

func ReadFileAndSplit

func ReadFileAndSplit(filename string) ([]string, error)

ReadFileAndSplit tokenizes the given file and converts in into a slice split by the newline character.

func RunCommand

func RunCommand(cmdname string, args ...string) error

RunCommand runs the given command with args and prints output

func RunCommandInput

func RunCommandInput(in io.Reader, cmdname string, args ...string) error

RunCommandInput runs the given command with args and input from an io.Reader, and prints output

func RunCommandOutput

func RunCommandOutput(cmdname string, args ...string) (*bytes.Buffer, error)

RunCommandOutput executes the command with arguments and stores its output in memory. If the command succeeds returns that output, if it fails, return err that contains both the out and err streams from the execution.

func RunCommandOutputEnv

func RunCommandOutputEnv(cmdname string, args []string, envs []string) (*bytes.Buffer, error)

RunCommandOutputEnv executes the command with arguments and environment and stores its output in memory. If the command succeeds returns that output, if it fails, return err that contains both the out and err streams from the execution.

func RunCommandSilent

func RunCommandSilent(cmdname string, args ...string) error

RunCommandSilent runs the given command with args and does not print output

func RunCommandTimeout

func RunCommandTimeout(timeout int, cmdname string, args ...string) error

RunCommandTimeout runs the given command with timeout + args and does not print command output

func UnpackFile

func UnpackFile(file string, dest string) error

UnpackFile unpacks a .tar or .tar.gz/.tgz file to a given directory. Should be roughly equivalent to "tar -x[z]f file -C dest". Does not overwrite; returns error if file being unpacked already exists.

Types

This section is empty.

Jump to

Keyboard shortcuts

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