Documentation ¶
Overview ¶
Package yamltemplate implements the YAML dialect of the ytt templating engine.
Index ¶
- Constants
- func HasTemplating(node yamlmeta.Node) bool
- func NewGoValueWithYAML(val interface{}) tplcore.GoValue
- func NewTemplateAnnotationFromYAMLComment(comment *yamlmeta.Comment, nodePos *filepos.Position, opts template.MetaOpts) (template.Annotation, error)
- type CommentAndAnnotation
- type EvaluationCtx
- func (e EvaluationCtx) PrepareNode(parentNode template.EvaluationNode, val template.EvaluationNode) error
- func (e EvaluationCtx) Replace(parentNodes []template.EvaluationNode, val interface{}) error
- func (e EvaluationCtx) SetMapItemKey(node template.EvaluationNode, val interface{}) error
- func (e EvaluationCtx) ShouldWrapRootValue(nodeVal interface{}) bool
- func (e EvaluationCtx) WrapRootValue(val interface{}) interface{}
- type MapItemOverride
- type Metas
- type StarlarkFragment
- func (s *StarlarkFragment) AsGoValue() (interface{}, error)
- func (s *StarlarkFragment) AsStarlarkValue() starlark.Value
- func (s *StarlarkFragment) CompareSameType(op syntax.Token, y starlark.Value, depth int) (bool, error)
- func (s *StarlarkFragment) Freeze()
- func (s *StarlarkFragment) Get(k starlark.Value) (v starlark.Value, found bool, err error)
- func (s *StarlarkFragment) Hash() (uint32, error)
- func (s *StarlarkFragment) Index(i int) starlark.Value
- func (s *StarlarkFragment) Items() []starlark.Tuple
- func (s *StarlarkFragment) Iterate() starlark.Iterator
- func (s *StarlarkFragment) Len() int
- func (s *StarlarkFragment) SetIndex(index int, v starlark.Value) error
- func (s *StarlarkFragment) SetKey(k, v starlark.Value) error
- func (s *StarlarkFragment) Slice(start, end, step int) starlark.Value
- func (s *StarlarkFragment) String() string
- func (s *StarlarkFragment) Truth() starlark.Bool
- func (s *StarlarkFragment) Type() string
- type StarlarkFragmentKeysIterator
- type StarlarkFragmentNilIterator
- type StarlarkFragmentValuesIterator
- type Template
- type TemplateOpts
Constants ¶
const (
AnnotationMapKeyOverride template.AnnotationName = "yaml/map-key-override"
)
const (
AnnotationTextTemplatedStrings template.AnnotationName = "yaml/text-templated-strings"
)
const (
EvaluationCtxDialectName template.EvaluationCtxDialectName = "yaml"
)
Variables ¶
This section is empty.
Functions ¶
func HasTemplating ¶ added in v0.48.0
func NewGoValueWithYAML ¶ added in v0.48.0
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
}
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
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 (*StarlarkFragment) Freeze ¶
func (s *StarlarkFragment) Freeze()
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()
type StarlarkFragmentNilIterator ¶ added in v0.48.0
type StarlarkFragmentNilIterator struct{}
func (StarlarkFragmentNilIterator) Done ¶ added in v0.48.0
func (s StarlarkFragmentNilIterator) Done()
type StarlarkFragmentValuesIterator ¶ added in v0.48.0
type StarlarkFragmentValuesIterator struct {
// contains filtered or unexported fields
}
func (*StarlarkFragmentValuesIterator) Done ¶ added in v0.48.0
func (s *StarlarkFragmentValuesIterator) Done()
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.