templates

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteTemplate

func ExecuteTemplate(tmplName string, tmpl GoTmpl, ctx *TemplateContext) (string, error)

ExecuteTemplate a template and return the rendered respnse or an error.

Types

type GoTmpl

type GoTmpl string

GoTmpl represents a go template string.

type TemplateContext

type TemplateContext struct {
	Params map[string]string
	Env    map[string]string
}

TemplateContext stores all contextual variables injected from the system and integration data store. ie - callback_url (data store), commit_hash (system var)

func NewTemplateContext

func NewTemplateContext(
	params map[string]string,
	envVars map[string]string) *TemplateContext

NewTemplateContext returns an instance of TemplateContext.

func (*TemplateContext) EnvExists

func (ctx *TemplateContext) EnvExists(key string) bool

EnvExists returns true if the environment key exists.

func (*TemplateContext) FindEnv

func (ctx *TemplateContext) FindEnv(key string) (string, error)

FindEnv returns the environment value by the specified key.

func (*TemplateContext) FindParam

func (ctx *TemplateContext) FindParam(needle string) (string, error)

FindParam returns a parameter value if exists otherwise returns an error.

func (*TemplateContext) ParamExists

func (ctx *TemplateContext) ParamExists(needle string) bool

ParamExists returns true if found a matching parameter.

Jump to

Keyboard shortcuts

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