util

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2017 License: Apache-2.0 Imports: 24 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanReadFile

func CanReadFile(path string) bool

If the file represented by path exists and readable, return true otherwise return false.

func DecryptText added in v1.0.0

func DecryptText(cryptoText string) (string, error)

Decrypt from base64 to decrypted string

func EncryptText added in v1.0.0

func EncryptText(text string) (string, error)

Encrypt string to base64 crypto using AES

func EscapeStringForSSHUse added in v1.0.0

func EscapeStringForSSHUse(s string) string

EscapeStringForSSHUse will parse string and replace shell special characters with escape

func GenerateSelfSignedCert

func GenerateSelfSignedCert(certPath, keyPath string, ips []net.IP, alternateDNS []string) error

You may also specify additional subject alt names (either ip or dns names) for the certificate The certificate will be created with file mode 0644. The key will be created with file mode 0600. If the certificate or key files already exist, they will be overwritten. Any parent directories of the certPath or keyPath will be created as needed with file mode 0755.

func HomeDir added in v1.0.0

func HomeDir() string

HomeDir returns the home directory for the current user

func Pad

func Pad(str string) string

func ReadInputFromStdin added in v1.0.0

func ReadInputFromStdin(fieldlabel string) string

func ReadPasswordFromStdin added in v1.0.0

func ReadPasswordFromStdin(fieldlabel string) string

func Retry

func Retry(attempts int, callback func() error) (err error)

func RetryAfter

func RetryAfter(attempts int, callback func() error, d time.Duration) (err error)

func Until

func Until(fn func() error, w io.Writer, name string, sleep time.Duration, done <-chan struct{})

Until endlessly loops the provided function until a message is received on the done channel. The function will wait the duration provided in sleep between function calls. Errors will be sent on provider Writer.

func ValidateProxyURI added in v1.0.0

func ValidateProxyURI(uri string) bool

func VersionOrdinal added in v1.0.0

func VersionOrdinal(version string) string

Types

type MultiError added in v0.3.5

type MultiError struct {
	Errors []error
}

func (*MultiError) Collect added in v0.3.5

func (m *MultiError) Collect(err error)

func (MultiError) ToError added in v0.3.5

func (m MultiError) ToError() error

type RealRunner added in v1.0.0

type RealRunner struct{}

func (RealRunner) Output added in v1.0.0

func (r RealRunner) Output(command string, args ...string) ([]byte, error)

the real runner for get the output as byte format

func (RealRunner) Run added in v1.0.0

func (r RealRunner) Run(stdOut io.Writer, stdErr io.Writer, commandPath string, args ...string) int

type Runner added in v1.0.0

type Runner interface {
	Run(stdOut io.Writer, stdErr io.Writer, commandPath string, args ...string) int
	Output(string, ...string) ([]byte, error)
}

Directories

Path Synopsis
os

Jump to

Keyboard shortcuts

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