templating

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2018 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FuncMap

func FuncMap() template.FuncMap

FuncMap returns a FuncMap representing all of the functionality of the engine.

func LoadAndRenderSteps

func LoadAndRenderSteps(template *Template, opts *BaseRenderOptions) (string, error)

LoadAndRenderSteps loads a template file and renders it according to an optional values file, --set values, and base render options.

Types

type BaseRenderOptions

type BaseRenderOptions struct {
	// Path to the task file.
	TaskFile string

	// Base64 encoded task file.
	Base64EncodedTaskFile string

	// Path to a values file.
	ValuesFile string

	// Base64 encoded values file.
	Base64EncodedValuesFile string

	// Override values.
	TemplateValues []string

	// ID is a unique identifier for the run.
	ID string

	// Commit is the SHA the run was triggered against.
	Commit string

	// Repository is the repository the run was triggered against.
	Repository string

	// Branch is the branch the run was triggered against.
	Branch string

	// TriggeredBy is the reason the run was triggered.
	TriggeredBy string

	// GitTag is the git tag the run was triggered against.
	GitTag string

	// Registry is the container registry being used.
	Registry string

	// Date is the UTC date of the run.
	Date time.Time

	// SharedVolume is the name of the shared volume.
	SharedVolume string

	// OS is the GOOS.
	OS string

	// Architecture is the GOARCH.
	Architecture string
}

BaseRenderOptions represents additional information for the composition of the final rendering.

type Config

type Config struct {
	RawValue string
	Values   map[string]*Value
}

Config represents configuration values.

func DecodeConfig added in v1.0.5

func DecodeConfig(encoded string) (*Config, error)

DecodeConfig loads a Config from a Base64 encoded string.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig creates a Config from the specified path.

func (*Config) GetRawValue

func (c *Config) GetRawValue() string

GetRawValue returns the Config's value as a string.

func (*Config) IsValidConfig

func (c *Config) IsValidConfig() bool

IsValidConfig determines whether or not the Config is valid.

type Engine

type Engine struct {
	FuncMap    template.FuncMap
	StrictMode bool
}

Engine is a wrapper around Go templates.

func NewEngine

func NewEngine() *Engine

NewEngine creates a new engine.

func (*Engine) Render

func (e *Engine) Render(t *Template, values Values) (string, error)

Render renders a template.

type Template

type Template struct {
	Name string
	Data []byte
}

Template represents a template.

func DecodeTemplate added in v1.0.5

func DecodeTemplate(encoded string) (*Template, error)

DecodeTemplate loads a Template from a Base64 encoded string.

func LoadTemplate

func LoadTemplate(path string) (*Template, error)

LoadTemplate loads a Template from the specified path.

func NewTemplate added in v1.0.7

func NewTemplate(name string, data []byte) *Template

NewTemplate creates a new template with the specified name and data. It will strip out any commented lines from data, i.e. lines beginning with #.

func (*Template) GetData

func (t *Template) GetData() []byte

GetData returns a Template's data.

func (*Template) GetName

func (t *Template) GetName() string

GetName returns a Template's name.

type Value

type Value struct {
	Value string
}

Value represents a configuration value.

type Values

type Values map[string]interface{}

Values represents a map of build values.

func Deserialize

func Deserialize(b []byte) (v Values, err error)

Deserialize will convert the specified bytes to a Values object.

func DeserializeFromFile

func DeserializeFromFile(fileName string) (Values, error)

DeserializeFromFile will parse the specified file name and convert it to a Values object.

func OverrideValues

func OverrideValues(c1 *Config, c2 *Config) (Values, error)

OverrideValues overrides the first config with the second.

func OverrideValuesWithBuildInfo

func OverrideValuesWithBuildInfo(c1 *Config, c2 *Config, opts *BaseRenderOptions) (Values, error)

OverrideValuesWithBuildInfo overrides the specified config's values and provides a default set of values.

func (Values) ToYAMLString

func (v Values) ToYAMLString() (string, error)

ToYAMLString encodes the Values object into a YAML string.

Jump to

Keyboard shortcuts

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