Documentation
¶
Overview ¶
Copyright 2025 The Forgejo Authors SPDX-License-Identifier: MIT
Copyright 2025 The Forgejo Authors SPDX-License-Identifier: MIT
Index ¶
- Constants
- func CartesianProduct(mapOfLists map[string][]any) []map[string]any
- func CopyFile(source, dest string) (err error)
- func Dryrun(ctx context.Context) bool
- func Exit()
- func GetOutboundIP() net.IP
- func JobError(ctx context.Context) error
- func Logger(ctx context.Context) logrus.FieldLogger
- func LoggerHook(ctx context.Context) logrus.Hook
- func MustRandName(size int) string
- func NewLineWriter(handlers ...LineHandler) io.Writer
- func SetJobError(ctx context.Context, err error)
- func SetPendingExitCode(exitCode RunnerExitCode)
- func Sha256(content string) string
- func Suicide(exitCode RunnerExitCode) error
- func WithDryrun(ctx context.Context, dryrun bool) context.Context
- func WithJobErrorContainer(ctx context.Context) context.Context
- func WithLogger(ctx context.Context, logger logrus.FieldLogger) context.Context
- func WithLoggerHook(ctx context.Context, hook logrus.Hook) context.Context
- type Conditional
- type Drawing
- type Executor
- func NewConditionalExecutor(conditional Conditional, trueExecutor, falseExecutor Executor) Executor
- func NewDebugExecutor(format string, args ...any) Executor
- func NewErrorExecutor(err error) Executor
- func NewInfoExecutor(format string, args ...any) Executor
- func NewParallelExecutor(parallel int, executors ...Executor) Executor
- func NewPipelineExecutor(executors ...Executor) Executor
- type LineHandler
- type MutexMap
- type Pen
- type RunnerExitCode
- type Style
- type Warning
Constants ¶
const ( StyleDoubleLine = iota StyleSingleLine StyleDashedLine StyleNoLine )
Styles
Variables ¶
This section is empty.
Functions ¶
func CartesianProduct ¶
CartesianProduct takes map of lists and returns list of unique tuples
func Exit ¶ added in v12.2.0
func Exit()
Exit with an exit code that was previously set in `SetPendingExitCode`, or success if it was never set.
func GetOutboundIP ¶
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 Logger ¶
func Logger(ctx context.Context) logrus.FieldLogger
Logger returns the appropriate logger for current context
func LoggerHook ¶
LoggerHook returns the appropriate logger hook for current context the hook affects job logger, not global logger
func MustRandName ¶
func NewLineWriter ¶
func NewLineWriter(handlers ...LineHandler) io.Writer
NewLineWriter creates a new instance of a line writer
func SetJobError ¶
func SetPendingExitCode ¶ added in v12.2.0
func SetPendingExitCode(exitCode RunnerExitCode)
When the program exits, store an exit code to be used at that time. If `SetPendingExitCode` is called multiple times only the first invocation will be saved.
func Suicide ¶ added in v12.2.0
func Suicide(exitCode RunnerExitCode) error
func WithDryrun ¶
WithDryrun adds a value to the context for dryrun
func WithJobErrorContainer ¶
WithJobErrorContainer adds a value to the context as a container for an error
func WithLogger ¶
WithLogger adds a value to the context for the logger
Types ¶
type Conditional ¶
Conditional define contract for the conditional predicate
type Executor ¶
Executor define contract for the steps of a workflow
func NewConditionalExecutor ¶
func NewConditionalExecutor(conditional Conditional, trueExecutor, falseExecutor Executor) Executor
NewConditionalExecutor creates a new executor based on conditions
func NewDebugExecutor ¶
NewDebugExecutor is an executor that logs messages
func NewErrorExecutor ¶
NewErrorExecutor creates a new executor that always errors out
func NewInfoExecutor ¶
NewInfoExecutor is an executor that logs messages
func NewParallelExecutor ¶
NewParallelExecutor creates a new executor from a parallel of other executors
func NewPipelineExecutor ¶
NewPipelineExecutor creates a new executor from a series of other executors
func (Executor) If ¶
func (e Executor) If(conditional Conditional) Executor
If 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
type LineHandler ¶
LineHandler is a callback function for handling a line
type MutexMap ¶
type MutexMap struct {
// contains filtered or unexported fields
}
MutexMap is basically a map[string]sync.Mutex which allows you to have one mutex per string key being locked. Unlike a map[string]sync.Mutex, this map will automatically remove the Mutexes from itself when they are not being waited for, preventing resource waste. It does this by keeping a reference count of the current Lock calls for the given key.
type RunnerExitCode ¶ added in v12.2.0
type RunnerExitCode int
const ( Success RunnerExitCode = iota CacheUnrecoverableError )
var PendingExitCode RunnerExitCode