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 = errors.New("template: cannot specify both 'source' and 'content'") 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 list of dependencies that were used. Used []dep.Dependency // Missing is the list of dependencies that were missing. Missing []dep.Dependency // 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 // LeftDelim and RightDelim are the template delimiters. LeftDelim string RightDelim string }
NewTemplateInput is used as input when creating the template.
type Scratch ¶
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
}
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.