util

package
v0.0.0-...-f3c9853 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllKeys

func AllKeys(maps ...map[string]string) []string

AllKeys returns a list of all unique keys from all maps.

func Contains

func Contains(in []string, val string) (ret bool)

Contains returns true if the string is contained within this list.

func Unqiue

func Unqiue(in []string) []string

Unique returns a unique array of strings.

Types

type Command

type Command struct {
	Errors []error
	Dir    string
	Name   string
	Args   []string
	Out    io.Writer
	Err    io.Writer
	In     io.Reader
	Env    map[string]string
	// contains filtered or unexported fields
}

Command is a struct containing the details of an external command to be executed.

func (*Command) Attempts

func (c *Command) Attempts() int

Attempts The number of times the command has been executed.

func (*Command) CurrentArgs

func (c *Command) CurrentArgs() []string

CurrentArgs returns the current command arguments.

func (*Command) CurrentDir

func (c *Command) CurrentDir() string

CurrentDir returns the current Dir.

func (*Command) CurrentEnv

func (c *Command) CurrentEnv() map[string]string

CurrentEnv returns the current environment variables.

func (*Command) CurrentName

func (c *Command) CurrentName() string

CurrentName returns the current name of the command.

func (*Command) DidError

func (c *Command) DidError() bool

DidError returns a boolean if any error occurred in any execution of the command.

func (*Command) DidFail

func (c *Command) DidFail() bool

DidFail returns a boolean if the command could not complete (errored on every attempt).

func (*Command) Error

func (c *Command) Error() error

Error returns the last error.

func (*Command) SetArgs

func (c *Command) SetArgs(args []string)

SetArgs Setter method for Args to enable use of interface instead of Command struct.

func (*Command) SetDir

func (c *Command) SetDir(dir string)

SetDir Setter method for Dir to enable use of interface instead of Command struct.

func (*Command) SetEnv

func (c *Command) SetEnv(env map[string]string)

SetEnv Setter method for Env to enable use of interface instead of Command struct.

func (*Command) SetEnvVariable

func (c *Command) SetEnvVariable(name string, value string)

SetEnvVariable sets an environment variable into the environment.

func (*Command) SetName

func (c *Command) SetName(name string)

SetName Setter method for Name to enable use of interface instead of Command struct.

func (*Command) String

func (c *Command) String() string

String string representation of this command.

type CommandError

type CommandError struct {
	Command Command
	Output  string
	// contains filtered or unexported fields
}

CommandError is the error object encapsulating an error from a Command.

func (CommandError) Error

func (c CommandError) Error() string

Error returns a sanitised error message.

type CommandRunner

type CommandRunner interface {
	RunWithoutRetry(c *Command) (string, error)
}

CommandRunner interface that wraps the RunWithoutRetry function.

type DefaultCommandRunner

type DefaultCommandRunner struct {
}

DefaultCommandRunner the default implementation of this, will actually execute things.

func (DefaultCommandRunner) RunWithoutRetry

func (d DefaultCommandRunner) RunWithoutRetry(c *Command) (string, error)

RunWithoutRetry Execute the command without retrying on failure and block waiting for return values.

type TextFormat

type TextFormat struct {
	ShowInfoLevel   bool
	ShowTimestamp   bool
	TimestampFormat string
}

TextFormat lets use a custom text format.

func NewTextFormat

func NewTextFormat() *TextFormat

NewTextFormat creates the default text formatter.

func (*TextFormat) Format

func (f *TextFormat) Format(entry *logrus.Entry) ([]byte, error)

Format formats the log statement.

Jump to

Keyboard shortcuts

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