scope

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Debug = false

Debug is debug mode flag

Functions

This section is empty.

Types

type CommandEvaluator

type CommandEvaluator interface {
	// Call executes a shell command
	Call(string) ([]byte, error)
}

CommandEvaluator represents command runner and wraps shell calls

type ExpressionProcessor

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

ExpressionProcessor evaluates template literals inside the string

func NewExpressionProcessor

func NewExpressionProcessor(ctx *Scope) ExpressionProcessor

NewExpressionProcessor creates a new processor instance

func (*ExpressionProcessor) ContainsExpression

func (p *ExpressionProcessor) ContainsExpression(str string) bool

ContainsExpression checks if passed string contains template expressions

func (*ExpressionProcessor) ReadExpression

func (p *ExpressionProcessor) ReadExpression(exp []byte) (result []byte, err error)

ReadExpression evaluates an expression string

func (*ExpressionProcessor) ReadString

func (p *ExpressionProcessor) ReadString(input string) (result string, err error)

ReadString parses and evaluates expressions inside the string

type Scope added in v0.4.0

type Scope struct {
	Globals   Vars // Globals is set of global variables for all tasks
	Variables Vars // Variables is set of variables for specific job

	Environment struct {
		ProjectDirectory string
	}
	// contains filtered or unexported fields
}

Scope contains a set of globals and variables related to specific job

func CreateScope added in v0.4.0

func CreateScope(projectDirectory string, vars Vars) (c *Scope)

CreateScope creates a new context

func (*Scope) AppendGlobals added in v0.4.0

func (c *Scope) AppendGlobals(globals Vars) *Scope

AppendGlobals appends global variables to the context

func (*Scope) AppendVariables added in v0.4.0

func (c *Scope) AppendVariables(vars Vars) *Scope

AppendVariables appends local variables to the context

func (*Scope) Environ added in v0.4.0

func (c *Scope) Environ() (env []string)

Environ gets list of OS environment variables with globals

func (*Scope) ExpandVariables added in v0.4.0

func (c *Scope) ExpandVariables(str string) (out string, err error)

ExpandVariables expands an expression stored inside a passed string

func (*Scope) Global added in v0.4.0

func (c *Scope) Global(varName string) (out string, ok bool)

Global returns a global variable value by it's name

func (*Scope) Scan added in v0.4.0

func (c *Scope) Scan(vals ...*string) (err error)

Scan does the same as ExpandVariables but with multiple variables and updates the value in pointer with expanded value

Useful for bulk mapping of struct fields

func (*Scope) Var added in v0.4.0

func (c *Scope) Var(varName string) (isLocal bool, out string, ok bool)

Var returns a local variable value by it's name

type Vars

type Vars map[string]string

Vars is a set of declared variables

func (Vars) Append added in v0.3.0

func (v Vars) Append(newVars Vars) (out Vars)

Append appends variables from vars list

func (Vars) AppendNew added in v0.5.0

func (v Vars) AppendNew(newVars Vars) (out Vars)

AppendNew does the same as Append but doesn't overwrite existing values

func (Vars) Clone added in v0.3.1

func (v Vars) Clone() (out Vars)

Clone creates a copy of variables map

Jump to

Keyboard shortcuts

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