Version: v0.17.0 Latest Latest

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

Go to latest
Published: Aug 25, 2017 License: MPL-2.0 Imports: 21 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type Brain

type Brain struct {
	// contains filtered or unexported fields

Brain is what Template uses to determine the values that are available for template parsing.

func NewBrain

func NewBrain() *Brain

NewBrain creates a new Brain with empty values for each of the key structs.

func (*Brain) ForceSet

func (b *Brain) ForceSet(hashCode string, data interface{})

ForceSet is used to force set the value of a dependency for a given hash code

func (*Brain) Forget

func (b *Brain) Forget(d dep.Dependency)

Forget accepts a dependency and removes all associated data with this dependency. It also resets the "receivedData" internal map.

func (*Brain) Recall

func (b *Brain) Recall(d dep.Dependency) (interface{}, bool)

Recall gets the current value for the given dependency in the Brain.

func (*Brain) Remember

func (b *Brain) Remember(d dep.Dependency, data interface{})

Remember accepts a dependency and the data to store associated with that dep. This function converts the given data to a proper type and stores it interally.

type Template

type Template struct {
	// Path is the path to this template on disk.
	Path string

	// LeftDelim and RightDelim are the left and right delimiters to use.
	LeftDelim, RightDelim string

	// Contents is the string contents for the template. It is either given
	// during template creation or read from disk when initialized.
	Contents string

	// HexMD5 stores the hex version of the MD5
	HexMD5 string

func NewTemplate

func NewTemplate(path, contents, leftDelim, rightDelim string) (*Template, error)

NewTemplate creates and parses a new Consul Template template at the given path. If the template does not exist, an error is returned. During initialization, the template is read and is parsed for dependencies. Any errors that occur are returned.

func (*Template) Execute

func (t *Template) Execute(brain *Brain) ([]dep.Dependency, []dep.Dependency, []byte, error)

Execute evaluates this template in the context of the given brain.

The first return value is the list of used dependencies. The second return value is the list of missing dependencies. The third return value is the rendered text. The fourth return value any error that occurs.

func (*Template) ID

func (t *Template) ID() string

ID returns an identifier for the template

Jump to

Keyboard shortcuts

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