template

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TestCompileMode = []compileFunc{
		verifyCommandsDefinedPass,
		failOnDeclarationWithNoResultPass,
		validateCommandsParamsPass,
		normalizeMissingRequiredParamsAsHolePass,
		checkInvalidReferenceDeclarationsPass,
		resolveHolesPass,
		resolveMissingHolesPass,
		resolveAliasPass,
		inlineVariableValuePass,
	}

	NewRunnerCompileMode = []compileFunc{
		verifyCommandsDefinedPass,
		failOnDeclarationWithNoResultPass,
		validateCommandsParamsPass,
		normalizeMissingRequiredParamsAsHolePass,
		checkInvalidReferenceDeclarationsPass,
		resolveHolesPass,
		resolveMissingHolesPass,
		resolveAliasPass,
		inlineVariableValuePass,
		failOnUnresolvedHolesPass,
		failOnUnresolvedAliasPass,
		convertParamsPass,
		validateCommandsPass,
		injectCommandsPass,
	}
)

Functions

func Compile

func Compile(tpl *Template, env *Env, mode ...Mode) (*Template, *Env, error)

func IsRevertible

func IsRevertible(t *Template) bool

func MatchStringParamValue added in v0.0.22

func MatchStringParamValue(s string) bool

func ParseParams

func ParseParams(text string) (map[string]interface{}, error)

Types

type Env

type Env struct {
	Lookuper LookupFunc
	IsDryRun bool

	ResolvedVariables map[string]interface{}

	Fillers          map[string]interface{}
	AliasFunc        func(entity, key, alias string) string
	MissingHolesFunc func(string) interface{}
	Log              *logger.Logger
	// contains filtered or unexported fields
}

func NewEnv

func NewEnv() *Env

func (*Env) AddFillers

func (e *Env) AddFillers(fills ...map[string]interface{})

func (*Env) GetProcessedFillers added in v0.0.25

func (e *Env) GetProcessedFillers() (copy map[string]interface{})

type Errors added in v0.0.23

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

func (*Errors) Error added in v0.0.23

func (d *Errors) Error() string

func (*Errors) Errors added in v0.0.23

func (d *Errors) Errors() ([]error, bool)

type LookupFunc added in v0.1.6

type LookupFunc func(...string) interface{}

type LookupGraphFunc

type LookupGraphFunc func(key string) (*graph.Graph, bool)

type Mode added in v0.0.23

type Mode []compileFunc

type ParamIsSetValidator added in v0.0.22

type ParamIsSetValidator struct {
	Entity, Action, Param, WarningMessage string
}

func (*ParamIsSetValidator) Execute added in v0.0.22

func (v *ParamIsSetValidator) Execute(t *Template) (errs []error)

type Runner added in v0.1.6

type Runner struct {
	Template                               *Template
	Locale, Profile, Message, TemplatePath string
	Log                                    *logger.Logger
	Fillers                                []map[string]interface{}
	AliasFunc                              func(entity, key, alias string) string
	MissingHolesFunc                       func(string) interface{}
	CmdLookuper                            func(tokens ...string) interface{}
	Validators                             []Validator

	BeforeRun func(*TemplateExecution) (bool, error)
	AfterRun  func(*TemplateExecution) error
}

func (*Runner) Run added in v0.1.6

func (ru *Runner) Run() error

type Template

type Template struct {
	ID string
	*ast.AST
}

func MustParse

func MustParse(text string) *Template

func Parse

func Parse(text string) (tmpl *Template, err error)

func (*Template) CommandNodesIterator

func (s *Template) CommandNodesIterator() (nodes []*ast.CommandNode)

func (*Template) CommandNodesReverseIterator added in v0.1.3

func (s *Template) CommandNodesReverseIterator() (nodes []*ast.CommandNode)

func (*Template) HasErrors

func (t *Template) HasErrors() bool

func (*Template) Revert

func (te *Template) Revert() (*Template, error)

func (*Template) Run

func (s *Template) Run(env *Env) (*Template, error)

func (*Template) UniqueDefinitions added in v0.0.21

func (t *Template) UniqueDefinitions(apis map[string]string) (res []string)

func (*Template) Validate

func (s *Template) Validate(rules ...Validator) (all []error)

func (*Template) WithRefsIterator added in v0.1.3

func (s *Template) WithRefsIterator() (nodes []ast.WithRefs)

type TemplateExecution added in v0.0.25

type TemplateExecution struct {
	*Template
	Author, Source, Locale string
	Profile, Path, Message string
	Fillers                map[string]interface{}
}

Allow template executions serialization with context for JSON storage without altering the template.Template model

func (*TemplateExecution) Date added in v0.1.5

func (t *TemplateExecution) Date() time.Time

Date extract the date from the ulid template identifier

func (*TemplateExecution) IsOneLiner added in v0.1.5

func (t *TemplateExecution) IsOneLiner() bool

func (*TemplateExecution) MarshalJSON added in v0.0.25

func (t *TemplateExecution) MarshalJSON() ([]byte, error)

func (*TemplateExecution) SetMessage added in v0.1.5

func (t *TemplateExecution) SetMessage(s string)

SetMessage set the value of Message, truncating it if exceeds max len

func (*TemplateExecution) Stats added in v0.1.5

func (*TemplateExecution) UnmarshalJSON added in v0.0.25

func (t *TemplateExecution) UnmarshalJSON(b []byte) error

type TemplateExecutionStats added in v0.1.5

type TemplateExecutionStats struct {
	KOCount, OKCount, CmdCount int
	ActionEntityCount          map[string]int
	Oneliner                   string
}

func (*TemplateExecutionStats) AllKO added in v0.1.5

func (te *TemplateExecutionStats) AllKO() bool

type UniqueNameValidator

type UniqueNameValidator struct {
	LookupGraph LookupGraphFunc
}

func (*UniqueNameValidator) Execute

func (v *UniqueNameValidator) Execute(t *Template) (errs []error)

type Validator

type Validator interface {
	Execute(t *Template) []error
}

Directories

Path Synopsis
fuzz
internal
ast

Jump to

Keyboard shortcuts

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