template

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TestCompileMode = []compileFunc{
		injectCommandsInNodesPass,
		failOnDeclarationWithNoResultPass,
		processAndValidateParamsPass,
		checkInvalidReferenceDeclarationsPass,
		resolveHolesPass,
		resolveMissingHolesPass,
		removeOptionalHolesPass,
		resolveAliasPass,
		inlineVariableValuePass,
		resolveParamsAndExtractRefsPass,
	}

	PreRevertCompileMode = []compileFunc{
		resolveParamsAndExtractRefsPass,
	}

	NewRunnerCompileMode = []compileFunc{
		injectCommandsInNodesPass,
		failOnDeclarationWithNoResultPass,
		processAndValidateParamsPass,
		checkInvalidReferenceDeclarationsPass,
		resolveHolesPass,
		resolveMissingHolesPass,
		removeOptionalHolesPass,
		resolveAliasPass,
		inlineVariableValuePass,
		failOnUnresolvedHolesPass,
		failOnUnresolvedAliasPass,
		resolveParamsAndExtractRefsPass,
		convertParamsPass,
		validateCommandsPass,
	}
)

Functions

func IsRevertible

func IsRevertible(t *Template) bool

func MatchStringParamValue

func MatchStringParamValue(s string) bool

func NewEnv

func NewEnv() *envBuilder

func NewRunEnv

func NewRunEnv(cenv env.Compiling, context ...map[string]any) env.Running

func ParseParams

func ParseParams(text string) (map[string]any, error)

Types

type LookupGraphFunc

type LookupGraphFunc func(key string) (cloud.GraphAPI, bool)

type Mode

type Mode []compileFunc

type ParamIsSetValidator

type ParamIsSetValidator struct {
	Entity, Action, Param, WarningMessage string
}

func (*ParamIsSetValidator) Execute

func (v *ParamIsSetValidator) Execute(t *Template) (errs []error)

type RunError

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

func (*RunError) Error

func (d *RunError) Error() string

func (*RunError) Errors

func (d *RunError) Errors() ([]error, bool)

type Runner

type Runner struct {
	Template                               *Template
	Locale, Profile, Message, TemplatePath string
	Log                                    *logger.Logger
	Fillers                                []map[string]any
	AliasFunc                              func(paramPath, alias string) string
	MissingHolesFunc                       func(string, []string, bool) string
	CmdLookuper                            func(tokens ...string) any
	Validators                             []Validator
	ParamsSuggested                        int

	// Ctx is the caller's context, propagated to every AWS call the template
	// makes. Leave nil in tests; Context() falls back to context.Background().
	Ctx context.Context

	BeforeRun func(*TemplateExecution) (bool, error)
	AfterRun  func(*TemplateExecution) error
}

func (*Runner) Context

func (ru *Runner) Context() context.Context

Context returns the runner's context, never nil.

func (*Runner) Run

func (ru *Runner) Run() error

type Template

type Template struct {
	ID string
	*ast.AST
}

func Compile

func Compile(tpl *Template, cenv env.Compiling, mode ...Mode) (*Template, env.Compiling, error)

func MustParse

func MustParse(text string) *Template

func Parse

func Parse(text string) (tmpl *Template, err error)

func (*Template) CommandNodesIterator

func (s *Template) CommandNodesIterator() (nodes []*ast.CommandNode)

func (*Template) CommandNodesReverseIterator

func (s *Template) CommandNodesReverseIterator() (nodes []*ast.CommandNode)

func (*Template) DryRun

func (s *Template) DryRun(renv env.Running) (tpl *Template, err error)

func (*Template) HasErrors

func (s *Template) HasErrors() bool

func (*Template) Revert

func (s *Template) Revert() (*Template, error)

func (*Template) Run

func (s *Template) Run(renv env.Running) (*Template, error)

func (*Template) UniqueDefinitions

func (s *Template) UniqueDefinitions(apis map[string]string) (res []string)

func (*Template) Validate

func (s *Template) Validate(rules ...Validator) (all []error)

type TemplateExecution

type TemplateExecution struct {
	*Template
	Author, Source, Locale string
	Profile, Path, Message string
	Fillers                map[string]any
}

Allow template executions serialization with context for JSON storage without altering the template.Template model

func (*TemplateExecution) Date

func (t *TemplateExecution) Date() time.Time

Date extract the date from the ulid template identifier

func (*TemplateExecution) IsOneLiner

func (t *TemplateExecution) IsOneLiner() bool

func (*TemplateExecution) MarshalJSON

func (t *TemplateExecution) MarshalJSON() ([]byte, error)

func (*TemplateExecution) SetMessage

func (t *TemplateExecution) SetMessage(s string)

SetMessage set the value of Message, truncating it if exceeds max len

func (*TemplateExecution) Stats

func (*TemplateExecution) UnmarshalJSON

func (t *TemplateExecution) UnmarshalJSON(b []byte) error

type TemplateExecutionStats

type TemplateExecutionStats struct {
	KOCount, OKCount, CmdCount int
	ActionEntityCount          map[string]int
	Oneliner                   string
}

func (*TemplateExecutionStats) AllKO

func (te *TemplateExecutionStats) AllKO() bool

type UniqueNameValidator

type UniqueNameValidator struct {
	LookupGraph LookupGraphFunc
}

func (*UniqueNameValidator) Execute

func (v *UniqueNameValidator) Execute(t *Template) (errs []error)

type Validator

type Validator interface {
	Execute(t *Template) []error
}

Directories

Path Synopsis
internal
ast
DO NOT EDIT This file was automatically generated with go generate
DO NOT EDIT This file was automatically generated with go generate

Jump to

Keyboard shortcuts

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