Documentation ¶
Index ¶
- Variables
- func Apply(tmpl []byte, data interface{}, funcs ...template.FuncMap) ([]byte, error)
- func Apply2(tmpl []byte, data interface{}, funcs ...template.FuncMap) ([]byte, error)
- func ContentInline(ctx context.Context) interface{}
- func ContentToFile(ctx context.Context) interface{}
- func ContextGetTemplateData(ctx context.Context) interface{}
- func ContextGetTimeout(ctx context.Context) time.Duration
- func ContextPutTemplateData(ctx context.Context, data interface{}) context.Context
- func ContextPutTimeout(ctx context.Context, duration time.Duration) context.Context
- func DefaultFuncMap(ctx context.Context) template.FuncMap
- func Execute(ctx context.Context, uri string, funcs ...template.FuncMap) ([]byte, error)
- func ExecuteShell(ctx context.Context) interface{}
- func GetEnvironmentVariable(ctx context.Context) interface{}
- func GetKeyForTemplate(tmpl []byte) string
- func IsUrl(s string) bool
- func MergeFuncMaps(a, b template.FuncMap) template.FuncMap
- func ParseHost(ctx context.Context) interface{}
- func ParseHostPort(ctx context.Context) interface{}
- func ParsePort(ctx context.Context) interface{}
- func RegisterFunc(name string, generator func(context.Context) interface{})
- type NotSupported
Constants ¶
This section is empty.
Variables ¶
var ( ErrMissingTemplateFunc = errors.New("err-no-template-func") ErrBadTemplateFunc = errors.New("err-bad-template-func") ErrNotImplemented = errors.New("err-not-implemented") )
var ( NullTemplate string = "" NullContent string = "" )
var (
TemplateDataContextKey templateDataContextKey = 1
)
var TimeoutContextKey timeoutContextKey = 1
Functions ¶
func Apply ¶
Generic Apply template. This is simple convenince wrapper that generates a hash key for the template name based on the template content itself.
func Apply2 ¶
Two-pass apply. This supports the notion of a define template block where the content is in YAML. The content in YAML is then parsed and in the second pass any template expressions that calls the function {{my <var>}} will access the values in the define blocks.
For example:
{{define "app"}} version: 1.2 image: repo build: 1234 {{end}}
{{define "host"}} label: appserver name: myhost {{end}}
{ "image" : "repo/myapp:{{my app.version}}-{{my app.build}}", "host" : "{{my host.name}}" }
Will turn into:
{ "image" : "repo/myapp:1.2-1234", "host" : "myhost" }
func ContentInline ¶
Fetch the url and write content inline ex) {{ inline "http://file/here" }}
func ContentToFile ¶
func ContextGetTemplateData ¶
func ContextPutTemplateData ¶
func ContextPutTimeout ¶
func Execute ¶
Execute a template at the given uri/url. The data to be applied to the template should be placed in the context via the ContextPutTemplateData() function.
func ExecuteShell ¶
This will bock until the shell executes to completion. The output to stdout is buffered internally and available for reading in the returned io.Reader. This function will block until all the data to stdout has been captured.
func GetEnvironmentVariable ¶
func GetKeyForTemplate ¶
func ParseHostPort ¶
TODO - Add support for interpreting URL string so we can pull from zk or http
func RegisterFunc ¶
Types ¶
type NotSupported ¶
type NotSupported struct {
Protocol string
}
func (*NotSupported) Error ¶
func (this *NotSupported) Error() string