Documentation ¶
Index ¶
- Variables
- type Brain
- type ExecuteInput
- type ExecuteResult
- type NewTemplateInput
- type Scratch
- func (s *Scratch) Get(k string) interface{}
- func (s *Scratch) Key(k string) bool
- func (s *Scratch) MapSet(k, mk string, v interface{}) (string, error)
- func (s *Scratch) MapSetX(k, mk string, v interface{}) (string, error)
- func (s *Scratch) MapValues(k string) ([]interface{}, error)
- func (s *Scratch) Set(k string, v interface{}) string
- func (s *Scratch) SetX(k string, v interface{}) string
- type Template
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTemplateContentsAndSource is the error returned when a template // specifies both a "source" and "content" argument, which is not valid. ErrTemplateContentsAndSource = errors.New("template: cannot specify both 'source' and 'content'") // ErrTemplateMissingContentsAndSource is the error returned when a template // does not specify either a "source" or "content" argument, which is not // valid. ErrTemplateMissingContentsAndSource = errors.New("template: must specify exactly one of 'source' or 'content'") )
Functions ¶
This section is empty.
Types ¶
type Brain ¶
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 ¶
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 ExecuteInput ¶
type ExecuteInput struct { // Brain is the brain where data for the template is stored. Brain *Brain // Env is a custom environment provided to the template for envvar resolution. // Values specified here will take precedence over any values in the // environment when using the `env` function. Env []string }
ExecuteInput is used as input to the template's execute function.
type ExecuteResult ¶
type ExecuteResult struct { // Used is the set of dependencies that were used. Used *dep.Set // Missing is the set of dependencies that were missing. Missing *dep.Set // Output is the rendered result. Output []byte }
ExecuteResult is the result of the template execution.
type NewTemplateInput ¶
type NewTemplateInput struct { // Source is the location on disk to the file. Source string // Contents are the raw template contents. Contents string // ErrMissingKey causes the template parser to exit immediately with an error // when a map is indexed with a key that does not exist. ErrMissingKey bool // LeftDelim and RightDelim are the template delimiters. LeftDelim string RightDelim string }
NewTemplateInput is used as input when creating the template.
type Scratch ¶
Scratch is a wrapper around a map which is used by the template.
func (*Scratch) MapSetX ¶
MapSetX behaves the same as MapSet, except it will not overwrite the map key if it already exists.
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
Template is the internal representation of an individual template to process. The template retains the relationship between it's contents and is responsible for it's own execution.
func NewTemplate ¶
func NewTemplate(i *NewTemplateInput) (*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(i *ExecuteInput) (*ExecuteResult, error)
Execute evaluates this template in the provided context.