util

package
v1.34.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2019 License: Apache-2.0 Imports: 28 Imported by: 6

Documentation

Index

Constants

View Source
const OpenShiftRegistryIp = "172.30.1.1"

Variables

This section is empty.

Functions

func AskForConfirmation added in v1.4.0

func AskForConfirmation(message string) bool

func CommandExecutesSuccessfully added in v1.11.0

func CommandExecutesSuccessfully(cmd string, args ...string) bool

CommandExecutesSuccessfully returns true if the command executed based on the exit code

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 FriendlyDuration added in v1.3.0

func FriendlyDuration(d time.Duration) time.Duration

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 GetPasswordKeyring added in v1.26.0

func GetPasswordKeyring(username string) (string, error)

Retrive password from OS native credential provider/keychain

func IsAdministrativeUser added in v1.18.0

func IsAdministrativeUser() bool

IsAdministrativeUser returns true when user is either root or Administrator

func IsDirectoryWritable added in v1.15.0

func IsDirectoryWritable(path string) bool

IsDirectoryWritable checks if the directory is writable or not by trying creating a temporary file Return true if directory is writable else false

func IsTtySupported added in v1.11.0

func IsTtySupported() bool

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 SetPasswordKeyring added in v1.26.0

func SetPasswordKeyring(username, password string) error

Store the registration password in OS native keychain

func TimeElapsed added in v1.4.0

func TimeElapsed(start time.Time, friendly bool) string

TimeElapsed is used to time the execution of a method.

func TimeTrack added in v1.2.0

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

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, defaultScheme string) error

ValidateProxyURL validates that the specified proxyURL is valid

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) OverrideHttpProxy added in v1.25.0

func (p *ProxyConfig) OverrideHttpProxy(proxy string)

Override proxy for local/intermediate proxy

func (*ProxyConfig) OverrideHttpsProxy added in v1.25.0

func (p *ProxyConfig) OverrideHttpsProxy(proxy string)

Override proxy for local/intermediate proxy

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 {
	Env []string
}

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, command string, args ...string) int

type RetriableError added in v1.7.0

type RetriableError struct {
	Err error
}

func (RetriableError) Error added in v1.7.0

func (r RetriableError) Error() string

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