Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCantGetCaller is raised when we can't calculate a caller of NewProjectLocation. ErrCantGetCaller = errors.New("can't get caller") // ErrCallerNotAllowed is raised when user tries to use this shell-out package // outside of allowed places. This package is deprecated from start and was // introduced to allow rewriting of shell code to Golang in small chunks. ErrCallerNotAllowed = errors.New("don't try use knative.dev/pkg/test/upgrade/shell package outside of allowed places") )
Functions ¶
func NewPrefixer ¶
NewPrefixer creates a new prefixer that forwards all calls to Write() to writer.Write() with all lines prefixed with the value of prefix. Having a function instead of a static prefix allows to print timestamps or other changing information.
Types ¶
type Executor ¶
type Executor interface { RunScript(script Script, args ...string) error RunFunction(fn Function, args ...string) error }
Executor represents a executor that can execute shell scripts and call functions directly.
func NewExecutor ¶
func NewExecutor(t TestingT, loc ProjectLocation, opts ...Option) Executor
NewExecutor creates a new executor.
type ExecutorConfig ¶
type ExecutorConfig struct { ProjectLocation Streams Labels Environ []string }
ExecutorConfig holds executor configuration options.
type Function ¶
Function represents a function, whom will be sourced from Script file, and executed.
type Labels ¶
type Labels struct { LabelOut string LabelErr string SkipDate bool DateFormat string PrefixFunc }
Labels holds a labels to be used to prefix Out and Err streams of executed shells scripts/functions.
type Option ¶
type Option func(*ExecutorConfig)
Option overrides configuration options in ExecutorConfig.
type PrefixFunc ¶
type PrefixFunc func(st StreamType, label string, config ExecutorConfig) string
PrefixFunc is used to build a prefix that will be added to each line of the script/function output or error stream.
type ProjectLocation ¶
type ProjectLocation interface {
RootPath() string
}
ProjectLocation represents a project location on a file system.
func NewProjectLocation ¶
func NewProjectLocation(pathToRoot string) (ProjectLocation, error)
NewProjectLocation creates a ProjectLocation that is used to calculate relative paths within the project.
type StreamType ¶
type StreamType int
StreamType represets either output or error stream.
const ( // StreamTypeOut represents process output stream. StreamTypeOut StreamType = iota // StreamTypeErr represents process error stream. StreamTypeErr )