yamltemplate

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package yamltemplate implements the YAML dialect of the ytt templating engine.

Index

Constants

View Source
const (
	AnnotationMapKeyOverride template.AnnotationName = "yaml/map-key-override"
)
View Source
const (
	AnnotationTextTemplatedStrings template.AnnotationName = "yaml/text-templated-strings"
)
View Source
const (
	EvaluationCtxDialectName template.EvaluationCtxDialectName = "yaml"
)

Variables

This section is empty.

Functions

func HasTemplating added in v0.48.0

func HasTemplating(node yamlmeta.Node) bool

func NewGoValueWithYAML added in v0.48.0

func NewGoValueWithYAML(val interface{}) tplcore.GoValue

func NewTemplateAnnotationFromYAMLComment added in v0.48.0

func NewTemplateAnnotationFromYAMLComment(comment *yamlmeta.Comment, nodePos *filepos.Position, opts template.MetaOpts) (template.Annotation, error)

NewTemplateAnnotationFromYAMLComment parses "comment" into template.Annotation. nodePos is the position of the node to which "comment" is attached.

When a comment contains a shorthand annotation (i.e. `#@ `):

  • if the comment is above its node, it's a template.AnnotationCode annotation: it's _merely_ contributing raw Starlark code.
  • if the comment is on the same line as its node, it's a template.AnnotationValue annotation: it's meant to set the value of the annotated node.

Types

type CommentAndAnnotation added in v0.48.0

type CommentAndAnnotation struct {
	Comment    *yamlmeta.Comment
	Annotation *template.Annotation
}

type EvaluationCtx

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

func (EvaluationCtx) PrepareNode

func (e EvaluationCtx) PrepareNode(parentNode template.EvaluationNode, val template.EvaluationNode) error

PrepareNode pre-processes the template.EvaluationNode so that the resulting AST fully reflects having been evaluated.

func (EvaluationCtx) Replace

func (e EvaluationCtx) Replace(
	parentNodes []template.EvaluationNode, val interface{}) error

func (EvaluationCtx) SetMapItemKey added in v0.17.0

func (e EvaluationCtx) SetMapItemKey(node template.EvaluationNode, val interface{}) error

func (EvaluationCtx) ShouldWrapRootValue

func (e EvaluationCtx) ShouldWrapRootValue(nodeVal interface{}) bool

func (EvaluationCtx) WrapRootValue

func (e EvaluationCtx) WrapRootValue(val interface{}) interface{}

type MapItemOverride

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

func (MapItemOverride) Apply

func (d MapItemOverride) Apply(
	typedMap *yamlmeta.Map, newItem *yamlmeta.MapItem, strict bool) error

type Metas

type Metas struct {
	Block       []*yamlmeta.Comment // meant to execute some code
	Values      []*yamlmeta.Comment // meant to return interpolated value
	Annotations []CommentAndAnnotation
	// contains filtered or unexported fields
}

Metas are the collection of ytt YAML templating values parsed from the comments attached to a yamlmeta.Node

func (Metas) NeedsEnd

func (m Metas) NeedsEnd() bool

type StarlarkFragment

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

StarlarkFragment is an adapter for yamlmeta.Node values in Starlark code

func NewStarlarkFragment

func NewStarlarkFragment(data interface{}) *StarlarkFragment

func (*StarlarkFragment) AsGoValue

func (s *StarlarkFragment) AsGoValue() (interface{}, error)

func (*StarlarkFragment) AsStarlarkValue

func (s *StarlarkFragment) AsStarlarkValue() starlark.Value

func (*StarlarkFragment) CompareSameType added in v0.48.0

func (s *StarlarkFragment) CompareSameType(op syntax.Token, y starlark.Value, depth int) (bool, error)

func (*StarlarkFragment) Freeze

func (s *StarlarkFragment) Freeze()

func (*StarlarkFragment) Get added in v0.48.0

func (s *StarlarkFragment) Get(k starlark.Value) (v starlark.Value, found bool, err error)

func (*StarlarkFragment) Hash

func (s *StarlarkFragment) Hash() (uint32, error)

func (*StarlarkFragment) Index added in v0.48.0

func (s *StarlarkFragment) Index(i int) starlark.Value

func (*StarlarkFragment) Items added in v0.48.0

func (s *StarlarkFragment) Items() []starlark.Tuple

Items seems to be only used for splatting kwargs

func (*StarlarkFragment) Iterate added in v0.48.0

func (s *StarlarkFragment) Iterate() starlark.Iterator

func (*StarlarkFragment) Len added in v0.48.0

func (s *StarlarkFragment) Len() int

func (*StarlarkFragment) SetIndex added in v0.48.0

func (s *StarlarkFragment) SetIndex(index int, v starlark.Value) error

func (*StarlarkFragment) SetKey added in v0.48.0

func (s *StarlarkFragment) SetKey(k, v starlark.Value) error

func (*StarlarkFragment) Slice added in v0.48.0

func (s *StarlarkFragment) Slice(start, end, step int) starlark.Value

func (*StarlarkFragment) String

func (s *StarlarkFragment) String() string

func (*StarlarkFragment) Truth

func (s *StarlarkFragment) Truth() starlark.Bool

func (*StarlarkFragment) Type

func (s *StarlarkFragment) Type() string

type StarlarkFragmentKeysIterator added in v0.48.0

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

func (*StarlarkFragmentKeysIterator) Done added in v0.48.0

func (s *StarlarkFragmentKeysIterator) Done()

func (*StarlarkFragmentKeysIterator) Next added in v0.48.0

type StarlarkFragmentNilIterator added in v0.48.0

type StarlarkFragmentNilIterator struct{}

func (StarlarkFragmentNilIterator) Done added in v0.48.0

func (s StarlarkFragmentNilIterator) Done()

func (StarlarkFragmentNilIterator) Next added in v0.48.0

type StarlarkFragmentValuesIterator added in v0.48.0

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

func (*StarlarkFragmentValuesIterator) Done added in v0.48.0

func (*StarlarkFragmentValuesIterator) Next added in v0.48.0

type Template

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

func NewTemplate

func NewTemplate(name string, opts TemplateOpts) *Template

func (*Template) Compile

func (e *Template) Compile(docSet *yamlmeta.DocumentSet) (*template.CompiledTemplate, error)

Compile converts a DocumentSet into code and metadata, returned via CompiledTemplate.

type TemplateOpts added in v0.12.0

type TemplateOpts struct {
	IgnoreUnknownComments   bool
	ImplicitMapKeyOverrides bool
}

Jump to

Keyboard shortcuts

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