template

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2017 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LenientCompileMode = []compileFunc{
		resolveAgainstDefinitions,
		checkInvalidReferenceDeclarations,
		resolveHolesPass,
		resolveMissingHolesPass,
		replaceVariableValuePass,
		removeValueStatementsPass,
		resolveAliasPass,
	}

	NormalCompileMode = append(
		LenientCompileMode,
		failOnUnresolvedHoles,
		failOnUnresolvedAlias,
	)
)

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 NewDefaultPrinter added in v0.0.20

func NewDefaultPrinter(w io.Writer) *defaultPrinter

func NewJSONPrinter added in v0.0.25

func NewJSONPrinter(w io.Writer) *jsonPrinter

func NewLogPrinter added in v0.0.20

func NewLogPrinter(w io.Writer) *logPrinter

func ParseParams

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

Types

type Definition added in v0.0.21

type Definition struct {
	Action, Entity, Api         string
	RequiredParams, ExtraParams []string
}

func (Definition) Extra added in v0.0.21

func (def Definition) Extra() []string

func (Definition) GetTemplate added in v0.0.21

func (def Definition) GetTemplate() (*Template, error)

func (Definition) Name added in v0.0.21

func (def Definition) Name() string

func (Definition) Required added in v0.0.21

func (def Definition) Required() []string

func (Definition) String added in v0.0.21

func (def Definition) String() string

type DefinitionLookupFunc added in v0.0.21

type DefinitionLookupFunc func(key string) (Definition, bool)

type Definitions added in v0.0.21

type Definitions []Definition

func (Definitions) Map added in v0.0.21

func (defs Definitions) Map(fn func(Definition) string) (reduced []string)

type Env

type Env struct {
	Driver driver.Driver

	ResolvedReferences map[string]interface{}

	Fillers          map[string]interface{}
	DefLookupFunc    DefinitionLookupFunc
	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 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 Printer

type Printer interface {
	Print(*TemplateExecution) 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) CmdNodesReverseIterator

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

func (*Template) CommandNodesIterator

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

func (*Template) DryRun added in v0.0.21

func (s *Template) DryRun(env *Env) error

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(fn DefinitionLookupFunc) (definitions Definitions)

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, Profile string
	Fillers                         map[string]interface{}
}

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

func (*TemplateExecution) MarshalJSON added in v0.0.25

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

func (*TemplateExecution) UnmarshalJSON added in v0.0.25

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

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
internal
ast

Jump to

Keyboard shortcuts

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