util

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2017 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const OpenShiftRegistryIp = "172.30.1.1"

Variables

This section is empty.

Functions

func DecryptText

func DecryptText(cryptoText string) (string, error)

Decrypt from base64 to decrypted string

func EncryptText

func EncryptText(text string) (string, error)

Encrypt string to base64 crypto using AES

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

func HomeDir() string

HomeDir returns the home directory for the current user

func Pad

func Pad(str string) string

func ReadInputFromStdin

func ReadInputFromStdin(fieldlabel string) string

func ReadPasswordFromStdin

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 TimeTrack added in v1.2.0

func TimeTrack(start time.Time, w io.Writer)

TimeTrack is used to time the execution of a method. It is passed the start time as well as a output writer for the timing. The usage of TimeTrack is in combination with defer like so:

defer TimeTrack(time.Now(), os.Stdout)

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 ValidateProxyURL added in v1.1.0

func ValidateProxyURL(proxyUrl string) error

validateProxyURL validates that the specified proxyURL is valid

func VersionOrdinal

func VersionOrdinal(version string) string

Types

type MultiError

type MultiError struct {
	Errors []error
}

func (*MultiError) Collect

func (m *MultiError) Collect(err error)

func (MultiError) ToError

func (m MultiError) ToError() error

type ProxyConfig added in v1.1.0

type ProxyConfig struct {
	// contains filtered or unexported fields
}

ProxyConfig keeps the proxy configuration for the current environment

func NewProxyConfig added in v1.1.0

func NewProxyConfig(httpProxy string, httpsProxy string, noProxy string) (*ProxyConfig, error)

NewProxyConfig creates a proxy configuration with the specified parameters. If a empty string is passed the corresponding environment variable is checked.

func (*ProxyConfig) AddNoProxy added in v1.1.0

func (p *ProxyConfig) AddNoProxy(host string)

AddNoProxy appends the specified host to the list of no proxied hosts.

func (*ProxyConfig) ApplyToEnvironment added in v1.1.0

func (p *ProxyConfig) ApplyToEnvironment()

Sets the current config as environment variables in the current process.

func (*ProxyConfig) HttpProxy added in v1.1.0

func (p *ProxyConfig) HttpProxy() string

HttpProxy returns the configured value for the HTTP proxy. The empty string is returned in case HTTP proxy is not set.

func (*ProxyConfig) HttpsProxy added in v1.1.0

func (p *ProxyConfig) HttpsProxy() string

HttpsProxy returns the configured value for the HTTPS proxy. The empty string is returned in case HTTPS proxy is not set.

func (*ProxyConfig) IsEnabled added in v1.1.0

func (p *ProxyConfig) IsEnabled() bool

Enabled returns true if at least one proxy (HTTP or HTTPS) is configured. Returns false otherwise.

func (*ProxyConfig) NoProxy added in v1.1.0

func (p *ProxyConfig) NoProxy() string

NoProxy returns a comma separated list of hosts for which proxies should not be applied.

func (*ProxyConfig) ProxyConfig added in v1.1.0

func (p *ProxyConfig) ProxyConfig() []string

ProxyConfig returns a the proxy configuration as a slice, one element for each of the potential settings HTTP_PROXY, HTTPS_PROXY and NO_PROXY. If proxies are not enabled an empty slice is returned.

type RealRunner

type RealRunner struct {
	Env []string
}

func (RealRunner) Output

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

the real runner for get the output as byte format

func (RealRunner) Run

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

type Runner

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