common

package
v0.246.3 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StyleDoubleLine = iota
	StyleSingleLine
	StyleDashedLine
	StyleNoLine
)

Styles

Variables

This section is empty.

Functions

func CartesianProduct

func CartesianProduct(mapOfLists map[string][]interface{}) []map[string]interface{}

CartesianProduct takes map of lists and returns list of unique tuples

func CopyDir

func CopyDir(source string, dest string) (err error)

CopyDir recursive copy of directory

func CopyFile

func CopyFile(source string, dest string) (err error)

CopyFile copy file

func Dryrun

func Dryrun(ctx context.Context) bool

Dryrun returns true if the current context is dryrun

func GetOutboundIP

func GetOutboundIP() net.IP

GetOutboundIP returns an outbound IP address of this machine. It tries to access the internet and returns the local IP address of the connection. If the machine cannot access the internet, it returns a preferred IP address from network interfaces. It returns nil if no IP address is found.

func JobError

func JobError(ctx context.Context) error

JobError returns the job error for current context if any

func Logger

func Logger(ctx context.Context) logrus.FieldLogger

Logger returns the appropriate logger for current context

func LoggerHook

func LoggerHook(ctx context.Context) logrus.Hook

LoggerHook returns the appropriate logger hook for current context the hook affects job logger, not global logger

func NewLineWriter

func NewLineWriter(handlers ...LineHandler) io.Writer

NewLineWriter creates a new instance of a line writer

func SetJobError

func SetJobError(ctx context.Context, err error)

func WithDryrun

func WithDryrun(ctx context.Context, dryrun bool) context.Context

WithDryrun adds a value to the context for dryrun

func WithJobErrorContainer

func WithJobErrorContainer(ctx context.Context) context.Context

WithJobErrorContainer adds a value to the context as a container for an error

func WithLogger

func WithLogger(ctx context.Context, logger logrus.FieldLogger) context.Context

WithLogger adds a value to the context for the logger

func WithLoggerHook

func WithLoggerHook(ctx context.Context, hook logrus.Hook) context.Context

WithLoggerHook adds a value to the context for the logger hook

Types

type Conditional

type Conditional func(ctx context.Context) bool

Conditional define contract for the conditional predicate

func (Conditional) Not

func (c Conditional) Not() Conditional

Not return an inverted conditional

type Drawing

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

Drawing struct

func (*Drawing) Draw

func (d *Drawing) Draw(writer io.Writer, centerOnWidth int)

Draw to writer

func (*Drawing) GetWidth

func (d *Drawing) GetWidth() int

GetWidth of drawing

type Executor

type Executor func(ctx context.Context) error

Executor define contract for the steps of a workflow

func NewConditionalExecutor

func NewConditionalExecutor(conditional Conditional, trueExecutor Executor, falseExecutor Executor) Executor

NewConditionalExecutor creates a new executor based on conditions

func NewDebugExecutor

func NewDebugExecutor(format string, args ...interface{}) Executor

NewDebugExecutor is an executor that logs messages

func NewErrorExecutor

func NewErrorExecutor(err error) Executor

NewErrorExecutor creates a new executor that always errors out

func NewInfoExecutor

func NewInfoExecutor(format string, args ...interface{}) Executor

NewInfoExecutor is an executor that logs messages

func NewParallelExecutor

func NewParallelExecutor(parallel int, executors ...Executor) Executor

NewParallelExecutor creates a new executor from a parallel of other executors

func NewPipelineExecutor

func NewPipelineExecutor(executors ...Executor) Executor

NewPipelineExecutor creates a new executor from a series of other executors

func (Executor) Finally

func (e Executor) Finally(finally Executor) Executor

Finally adds an executor to run after other executor

func (Executor) If

func (e Executor) If(conditional Conditional) Executor

If only runs this executor if conditional is true

func (Executor) IfBool

func (e Executor) IfBool(conditional bool) Executor

IfBool only runs this executor if conditional is true

func (Executor) IfNot

func (e Executor) IfNot(conditional Conditional) Executor

IfNot only runs this executor if conditional is true

func (Executor) Then

func (e Executor) Then(then Executor) Executor

Then runs another executor if this executor succeeds

type LineHandler

type LineHandler func(line string) bool

LineHandler is a callback function for handling a line

type Pen

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

Pen struct

func NewPen

func NewPen(style Style, color int) *Pen

NewPen creates a new pen

func (*Pen) DrawArrow

func (p *Pen) DrawArrow() *Drawing

DrawArrow between boxes

func (*Pen) DrawBoxes

func (p *Pen) DrawBoxes(labels ...string) *Drawing

DrawBoxes to draw boxes

type Style

type Style int

Style is a specific style

type Warning

type Warning struct {
	Message string
}

Warning that implements `error` but safe to ignore

func Warningf

func Warningf(format string, args ...interface{}) Warning

Warningf create a warning

func (Warning) Error

func (w Warning) Error() string

Error the contract for error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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