util

package
v1.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const OpenShiftRegistryIp = "172.30.1.1"

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

func EscapeSingleQuote(s string) string

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

func ValidateProxyURL(proxyUrl string) error

validateProxyURL validates that the specified proxyURL is valid

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 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 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