template

package
Version: v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TestCompileMode = []compileFunc{
		injectCommandsInNodesPass,
		failOnDeclarationWithNoResultPass,
		processAndValidateParamsPass,
		checkInvalidReferenceDeclarationsPass,
		resolveHolesPass,
		resolveMissingHolesPass,
		removeOptionalHolesPass,
		resolveAliasPass,
		inlineVariableValuePass,
		resolveParamsAndExtractRefsPass,
	}

	PreRevertCompileMode = []compileFunc{
		resolveParamsAndExtractRefsPass,
	}

	NewRunnerCompileMode = []compileFunc{
		injectCommandsInNodesPass,
		failOnDeclarationWithNoResultPass,
		processAndValidateParamsPass,
		checkInvalidReferenceDeclarationsPass,
		resolveHolesPass,
		resolveMissingHolesPass,
		removeOptionalHolesPass,
		resolveAliasPass,
		inlineVariableValuePass,
		failOnUnresolvedHolesPass,
		failOnUnresolvedAliasPass,
		resolveParamsAndExtractRefsPass,
		convertParamsPass,
		validateCommandsPass,
	}
)

Functions

func IsRevertible

func IsRevertible(t *Template) bool

func MatchStringParamValue added in v0.0.22

func MatchStringParamValue(s string) bool

func NewEnv

func NewEnv() *envBuilder

func NewRunEnv added in v0.1.9

func NewRunEnv(cenv env.Compiling, context ...map[string]interface{}) env.Running

func ParseParams

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

Types

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 LookupGraphFunc

type LookupGraphFunc func(key string) (cloud.GraphAPI, 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(paramPath, alias string) string
	MissingHolesFunc                       func(string, []string, bool) string
	CmdLookuper                            func(tokens ...string) interface{}
	Validators                             []Validator
	ParamsSuggested                        int

	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 Compile

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

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) DryRun added in v0.0.21

func (s *Template) DryRun(renv env.Running) (tpl *Template, err error)

func (*Template) HasErrors

func (t *Template) HasErrors() bool

func (*Template) Revert

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

func (*Template) Run

func (s *Template) Run(renv env.Running) (*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)

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