Documentation
¶
Index ¶
- Variables
- func AddIfNotExist(values []string, value string) []string
- func CopyMap(m map[string]interface{}) map[string]interface{}
- func CopyStringMap(m map[string]string) map[string]string
- func GetValue(key string, value interface{}) (res interface{}, err error)
- func Lookup(command string) (string, error)
- func MapErr[T any, R any](collection []T, iteratee func(T, int) (R, error)) ([]R, error)
- func MultiWriteCloser(wc ...io.WriteCloser) io.WriteCloser
- func NewLineOrReturnScanner(reader io.Reader) *bufio.Scanner
- func ReaderToBufFunc(reader io.Reader, buf *bytes.Buffer) func() error
- func ReaderToCallbackFunc(ctx context.Context, reader io.Reader, callback func(string)) func() error
- func ReaderToLogFunc(reader io.Reader, logToErr bool, prefix string, logger Logger, subject string) func() error
- func SafeSplit(s string) []string
- func ScanNewLineOrReturn(data []byte, atEOF bool) (advance int, token []byte, err error)
- func ToEnvVariableName(str string) string
- func ToObjectViaJson[T any](from any, to *T) (*T, error)
- func ToSnakeCase(str string) string
- func TrimStringMiddle(str string, maxLen int, sep string) string
- type Console
- type ConsoleImpl
- func (c *ConsoleImpl) AlwaysRespondDefault() *ConsoleImpl
- func (c *ConsoleImpl) AskQuestion(question string) (string, error)
- func (c *ConsoleImpl) AskQuestionWithDefault(question string, defaultResponse string) (string, error)
- func (c *ConsoleImpl) AskYesNoQuestionWithDefault(question string, yes bool) (bool, error)
- func (c *ConsoleImpl) Reader() ConsoleReader
- func (c *ConsoleImpl) SetReader(reader ConsoleReader)
- func (c *ConsoleImpl) SetWriter(writer ConsoleWriter)
- func (c *ConsoleImpl) Writer() ConsoleWriter
- type ConsoleReader
- type ConsoleWriter
- type Data
- type Exec
- type ExecOpts
- type ExecRes
- type Logger
- type NoopLogger
- func (l *NoopLogger) Debugf(format string, msg ...interface{})
- func (l *NoopLogger) Err(msg string)
- func (l *NoopLogger) Errf(format string, msg ...interface{})
- func (l *NoopLogger) Log(msg string)
- func (l *NoopLogger) Logf(format string, msg ...interface{})
- func (l *NoopLogger) SubLogger(name string) Logger
- type PrefixLogger
- func (l *PrefixLogger) Debugf(format string, msg ...interface{})
- func (l *PrefixLogger) Err(msg string)
- func (l *PrefixLogger) Errf(format string, msg ...interface{})
- func (l *PrefixLogger) Log(msg string)
- func (l *PrefixLogger) Logf(format string, msg ...interface{})
- func (l *PrefixLogger) SubLogger(name string) Logger
- func (l *PrefixLogger) WithTimeFormat(format string) *PrefixLogger
- type StdinConsoleReader
- type StdoutConsoleWriter
- type StdoutLogger
- func (l *StdoutLogger) Debug() *StdoutLogger
- func (l *StdoutLogger) Debugf(format string, msg ...interface{})
- func (l *StdoutLogger) Err(msg string)
- func (l *StdoutLogger) Errf(format string, msg ...interface{})
- func (l *StdoutLogger) Log(msg string)
- func (l *StdoutLogger) Logf(format string, msg ...interface{})
- func (l *StdoutLogger) SubLogger(name string) Logger
Constants ¶
This section is empty.
Variables ¶
var ( DefaultConsoleReader ConsoleReader = StdinConsoleReader{} DefaultConsoleWriter ConsoleWriter = StdoutConsoleWriter{} )
Functions ¶
func AddIfNotExist ¶
func GetValue ¶
GetValue allows to extract value from the provided object by the "path" inside of its structure Example:
With the following object: map[string]interface{}{"a": map[string]interface{}{"b": "c"}}
the value "c" can be reached by "a.b.c"
func MultiWriteCloser ¶
func MultiWriteCloser(wc ...io.WriteCloser) io.WriteCloser
MultiWriteCloser multiWriteCloser creates a WriteCloser that duplicates its writes and closes to all the provided writers.
func ReaderToBufFunc ¶
ReaderToBufFunc returns function that should be called in a goroutine. It reads lines from a provided reader and writes each one into the provided buffer
func ReaderToCallbackFunc ¶
func ReaderToCallbackFunc(ctx context.Context, reader io.Reader, callback func(string)) func() error
ReaderToCallbackFunc returns function that is meant to be called from a separate goroutine function starts streaming from reader to logger and appends extra prefix to each line
func ReaderToLogFunc ¶
func ReaderToLogFunc(reader io.Reader, logToErr bool, prefix string, logger Logger, subject string) func() error
ReaderToLogFunc returns function that is meant to be called from a separate goroutine function starts streaming from reader to logger and appends extra prefix to each line
func ScanNewLineOrReturn ¶
func ToEnvVariableName ¶
func ToObjectViaJson ¶
func ToSnakeCase ¶
Types ¶
type Console ¶
type Console interface {
AskYesNoQuestionWithDefault(question string, yes bool) (bool, error)
AskQuestionWithDefault(question string, defaultResponse string) (string, error)
AskQuestion(question string) (string, error)
Writer() ConsoleWriter
Reader() ConsoleReader
SetReader(reader ConsoleReader)
SetWriter(writer ConsoleWriter)
}
type ConsoleImpl ¶
type ConsoleImpl struct {
// contains filtered or unexported fields
}
func NewDefaultConsole ¶
func NewDefaultConsole() *ConsoleImpl
func (*ConsoleImpl) AlwaysRespondDefault ¶
func (c *ConsoleImpl) AlwaysRespondDefault() *ConsoleImpl
func (*ConsoleImpl) AskQuestion ¶
func (c *ConsoleImpl) AskQuestion(question string) (string, error)
func (*ConsoleImpl) AskQuestionWithDefault ¶
func (c *ConsoleImpl) AskQuestionWithDefault(question string, defaultResponse string) (string, error)
func (*ConsoleImpl) AskYesNoQuestionWithDefault ¶
func (c *ConsoleImpl) AskYesNoQuestionWithDefault(question string, yes bool) (bool, error)
func (*ConsoleImpl) Reader ¶
func (c *ConsoleImpl) Reader() ConsoleReader
func (*ConsoleImpl) SetReader ¶
func (c *ConsoleImpl) SetReader(reader ConsoleReader)
func (*ConsoleImpl) SetWriter ¶
func (c *ConsoleImpl) SetWriter(writer ConsoleWriter)
func (*ConsoleImpl) Writer ¶
func (c *ConsoleImpl) Writer() ConsoleWriter
type ConsoleReader ¶
type ConsoleWriter ¶
type ConsoleWriter interface {
Print(args ...interface{})
Println(args ...interface{})
}
type Exec ¶
type Exec struct {
// contains filtered or unexported fields
}
Exec defines execution on host environment
func NewExecWithOutput ¶
NewExecWithOutput initializes new host executor
func (*Exec) ExecCommand ¶
ExecCommand executes command and returns output
func (*Exec) ExecCommandAndLog ¶
ExecCommandAndLog executes command and logs into the provided logger
type NoopLogger ¶
type NoopLogger struct{}
func (*NoopLogger) Debugf ¶
func (l *NoopLogger) Debugf(format string, msg ...interface{})
func (*NoopLogger) Err ¶
func (l *NoopLogger) Err(msg string)
func (*NoopLogger) Errf ¶
func (l *NoopLogger) Errf(format string, msg ...interface{})
func (*NoopLogger) Log ¶
func (l *NoopLogger) Log(msg string)
func (*NoopLogger) Logf ¶
func (l *NoopLogger) Logf(format string, msg ...interface{})
func (*NoopLogger) SubLogger ¶
func (l *NoopLogger) SubLogger(name string) Logger
type PrefixLogger ¶
type PrefixLogger struct {
// contains filtered or unexported fields
}
func (*PrefixLogger) Debugf ¶
func (l *PrefixLogger) Debugf(format string, msg ...interface{})
func (*PrefixLogger) Err ¶
func (l *PrefixLogger) Err(msg string)
func (*PrefixLogger) Errf ¶
func (l *PrefixLogger) Errf(format string, msg ...interface{})
func (*PrefixLogger) Log ¶
func (l *PrefixLogger) Log(msg string)
func (*PrefixLogger) Logf ¶
func (l *PrefixLogger) Logf(format string, msg ...interface{})
func (*PrefixLogger) SubLogger ¶
func (l *PrefixLogger) SubLogger(name string) Logger
func (*PrefixLogger) WithTimeFormat ¶
func (l *PrefixLogger) WithTimeFormat(format string) *PrefixLogger
type StdinConsoleReader ¶
type StdinConsoleReader struct{}
func (StdinConsoleReader) ReadLine ¶
func (reader StdinConsoleReader) ReadLine() (string, error)
func (StdinConsoleReader) ReadPassword ¶
func (reader StdinConsoleReader) ReadPassword() (string, error)
type StdoutConsoleWriter ¶
type StdoutConsoleWriter struct{}
func (StdoutConsoleWriter) Print ¶
func (w StdoutConsoleWriter) Print(args ...interface{})
func (StdoutConsoleWriter) Println ¶
func (w StdoutConsoleWriter) Println(args ...interface{})
type StdoutLogger ¶
type StdoutLogger struct {
// contains filtered or unexported fields
}
func NewStdoutLogger ¶
func NewStdoutLogger(stdout io.WriteCloser, stderr io.WriteCloser) *StdoutLogger
func (*StdoutLogger) Debug ¶
func (l *StdoutLogger) Debug() *StdoutLogger
func (*StdoutLogger) Debugf ¶
func (l *StdoutLogger) Debugf(format string, msg ...interface{})
func (*StdoutLogger) Err ¶
func (l *StdoutLogger) Err(msg string)
func (*StdoutLogger) Errf ¶
func (l *StdoutLogger) Errf(format string, msg ...interface{})
func (*StdoutLogger) Log ¶
func (l *StdoutLogger) Log(msg string)
func (*StdoutLogger) Logf ¶
func (l *StdoutLogger) Logf(format string, msg ...interface{})
func (*StdoutLogger) SubLogger ¶
func (l *StdoutLogger) SubLogger(name string) Logger