gotemplate

package
v0.104.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSourceSnippet

func CreateSourceSnippet(errorLine, errorColumn int, source []string) string

CreateSourceSnippet creates an excerpt of lines of source code, containing some lines before and after the error line. The error line and column will be highlighted and looks like this: 14: updateStrategy: patch 15: 16: name: test 17: namespace: {{ .imports.namaspace }}

ˆ≈≈≈≈≈≈≈

18: 19: exportsFromManifests: 20: - key: ingressClass

func LandscaperSprigFuncMap

func LandscaperSprigFuncMap() gotmpl.FuncMap

LandscaperSprigFuncMap returns the sanitized spring function map.

func LandscaperTplFuncMap

func LandscaperTplFuncMap(blueprint *blueprints.Blueprint,
	componentVersion model.ComponentVersion,
	componentVersions *model.ComponentVersionList,
	targetResolver targetresolver.TargetResolver) (map[string]interface{}, error)

LandscaperTplFuncMap contains all additional landscaper functions that are available in the executors templates.

Types

type NoValueError

type NoValueError struct {
	// contains filtered or unexported fields
}

NoValueError is used for when an executed template result contains fields with "no value".

func CreateErrorIfContainsNoValue

func CreateErrorIfContainsNoValue(templateResult, templateName string, input map[string]interface{}, inputFormatter *template.TemplateInputFormatter) *NoValueError

CreateErrorIfContainsNoValue creates a NoValueError when the template result contains the "no value" string, otherwise nil is returned.

func (*NoValueError) Error

func (e *NoValueError) Error() string

Error returns the error message.

type StateTemplateResult

type StateTemplateResult struct {
	State json.RawMessage `json:"state"`
}

StateTemplateResult describes the result of go templating.

type TemplateError

type TemplateError struct {
	// contains filtered or unexported fields
}

TemplateError wraps a go templating error and adds more human-readable information.

func TemplateErrorBuilder

func TemplateErrorBuilder(err error) *TemplateError

TemplateErrorBuilder creates a new TemplateError.

func (*TemplateError) Build

func (e *TemplateError) Build() *TemplateError

Build builds the error message.

func (*TemplateError) Error

func (e *TemplateError) Error() string

Error returns the error message.

func (*TemplateError) WithInput

func (e *TemplateError) WithInput(input map[string]interface{}, inputFormatter *template.TemplateInputFormatter) *TemplateError

WithInput adds the template input with a formatter to the error.

func (*TemplateError) WithSource

func (e *TemplateError) WithSource(source *string) *TemplateError

WithSource adds the template source code to the error.

type TemplateExecution

type TemplateExecution struct {
	// contains filtered or unexported fields
}

func (*TemplateExecution) Execute

func (te *TemplateExecution) Execute(template string, binding interface{}) ([]byte, error)

type Templater

type Templater struct {
	// contains filtered or unexported fields
}

Templater is the go template implementation for landscaper templating.

func New

New creates a new go template execution templater.

func (*Templater) TemplateDeployExecutions

func (t *Templater) TemplateDeployExecutions(tmplExec lsv1alpha1.TemplateExecutor,
	blueprint *blueprints.Blueprint,
	descriptor model.ComponentVersion,
	cdList *model.ComponentVersionList,
	values map[string]interface{}) (*lstmpl.DeployExecutorOutput, error)

TemplateDeployExecutions is the GoTemplate executor for a deploy execution.

func (*Templater) TemplateExecution

func (t *Templater) TemplateExecution(rawTemplate string,
	blueprint *blueprints.Blueprint,
	cd model.ComponentVersion,
	cdList *model.ComponentVersionList,
	values map[string]interface{}) ([]byte, error)

func (*Templater) TemplateExportExecutions

func (t *Templater) TemplateExportExecutions(tmplExec lsv1alpha1.TemplateExecutor,
	blueprint *blueprints.Blueprint,
	descriptor model.ComponentVersion,
	cdList *model.ComponentVersionList,
	values map[string]interface{}) (*lstmpl.ExportExecutorOutput, error)

func (*Templater) TemplateImportExecutions

func (t *Templater) TemplateImportExecutions(tmplExec lsv1alpha1.TemplateExecutor,
	blueprint *blueprints.Blueprint,
	descriptor model.ComponentVersion,
	cdList *model.ComponentVersionList,
	values map[string]interface{}) (*lstmpl.ImportExecutorOutput, error)

TemplateImportExecutions is the GoTemplate executor for an import execution.

func (*Templater) TemplateSubinstallationExecutions

func (t *Templater) TemplateSubinstallationExecutions(tmplExec lsv1alpha1.TemplateExecutor,
	blueprint *blueprints.Blueprint,
	cd model.ComponentVersion,
	cdList *model.ComponentVersionList,
	values map[string]interface{}) (*lstmpl.SubinstallationExecutorOutput, error)

func (Templater) Type

func (*Templater) WithInputFormatter

func (t *Templater) WithInputFormatter(inputFormatter *lstmpl.TemplateInputFormatter) *Templater

WithInputFormatter ads a custom input formatter to this templater used for error messages.

Jump to

Keyboard shortcuts

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