template

package
v0.0.23 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

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

	NormalCompileMode = []compileFunc{
		resolveAgainstDefinitions,
		checkReferencesDeclaration,
		resolveHolesPass,
		resolveMissingHolesPass,
		resolveAliasPass,
		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 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 {
	Fillers map[string]interface{}

	Resolved         map[string]interface{}
	DefLookupFunc    DefinitionLookupFunc
	AliasFunc        func(entity, key, alias string) string
	MissingHolesFunc func(string) interface{}

	Log *logger.Logger
}

func NewEnv

func NewEnv() *Env

func (*Env) AddFillers

func (e *Env) AddFillers(fills ...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(*Template)
}

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(d driver.Driver) error

func (*Template) HasErrors

func (t *Template) HasErrors() bool

func (*Template) MarshalJSON

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

func (*Template) Revert

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

func (*Template) Run

func (s *Template) Run(d driver.Driver) (*Template, error)

func (*Template) UniqueDefinitions added in v0.0.21

func (t *Template) UniqueDefinitions(fn DefinitionLookupFunc) (definitions Definitions)

func (*Template) UnmarshalJSON

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

func (*Template) Validate

func (s *Template) Validate(rules ...Validator) (all []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