helpers

package
v4.3.2+incompatible Latest Latest
Warning

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

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

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 Download

func Download(filename string, url string) (err error)

Download will attempt to download a from URL to the given filename

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 PrintError

func PrintError(e error)

PrintError is a utility function to emit an error to the console

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 RunCommandSilent

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

RunCommandSilent runs the given command with args and does not print 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