Documentation ¶
Overview ¶
Package overlay implements YAML patching via ytt annotations.
Index ¶
- Constants
- Variables
- func AnnotateForPlainMerge(node yamlmeta.Node) error
- type ArrayItemMatchAnnotation
- type AssertAnnotation
- type Comparison
- type DocumentMatchAnnotation
- type InsertAnnotation
- type MapItemMatchAnnotation
- type MatchAnnotationExpectsKwarg
- type MatchAnnotationNumMatchError
- type MatchChildDefaultsAnnotation
- type Op
- type ReplaceAnnotation
Constants ¶
View Source
const ( AnnotationNs template.AnnotationNs = "overlay" AnnotationMerge template.AnnotationName = "overlay/merge" // default AnnotationRemove template.AnnotationName = "overlay/remove" AnnotationReplace template.AnnotationName = "overlay/replace" AnnotationInsert template.AnnotationName = "overlay/insert" // array only AnnotationAppend template.AnnotationName = "overlay/append" // array only AnnotationAssert template.AnnotationName = "overlay/assert" AnnotationMatch template.AnnotationName = "overlay/match" AnnotationMatchChildDefaults template.AnnotationName = "overlay/match-child-defaults" )
View Source
const ( InsertAnnotationKwargBefore string = "before" InsertAnnotationKwargAfter string = "after" InsertAnnotationKwargVia string = "via" )
Kwargs of overlay/insert
View Source
const ( MatchAnnotationKwargBy string = "by" MatchAnnotationKwargExpects string = "expects" MatchAnnotationKwargMissingOK string = "missing_ok" MatchAnnotationKwargWhen string = "when" )
View Source
const ( ReplaceAnnotationKwargVia string = "via" ReplaceAnnotationKwargOrAdd string = "or_add" )
Variables ¶
View Source
var ( API = starlark.StringDict{ "overlay": &starlarkstruct.Module{ Name: "overlay", Members: starlark.StringDict{ "apply": starlark.NewBuiltin("overlay.apply", core.ErrWrapper(overlayModule{}.Apply)), "index": starlark.NewBuiltin("overlay.index", core.ErrWrapper(overlayModule{}.Index)), "all": starlark.NewBuiltin("overlay.all", core.ErrWrapper(overlayModule{}.All)), "map_key": overlayModule{}.MapKey(), "subset": starlark.NewBuiltin("overlay.subset", core.ErrWrapper(overlayModule{}.Subset)), "and_op": starlark.NewBuiltin("overlay.and_op", core.ErrWrapper(overlayModule{}.AndOp)), "or_op": starlark.NewBuiltin("overlay.or_op", core.ErrWrapper(overlayModule{}.OrOp)), "not_op": starlark.NewBuiltin("overlay.not_op", core.ErrWrapper(overlayModule{}.NotOp)), }, }, } )
Functions ¶
func AnnotateForPlainMerge ¶ added in v0.48.0
AnnotateForPlainMerge configures `node` to be an overlay doing a "plain merge": - allow new keys via `@overlay/match missing_ok=True` - allow arrays and scalars to be replaced with given value (regardless of type) via `@overlay/replace or_add=True`
Returns an error when `node` contains templating; `node` must be plain YAML.
Types ¶
type ArrayItemMatchAnnotation ¶
type ArrayItemMatchAnnotation struct {
// contains filtered or unexported fields
}
func NewArrayItemMatchAnnotation ¶
func NewArrayItemMatchAnnotation(newItem *yamlmeta.ArrayItem, defaults MatchChildDefaultsAnnotation, thread *starlark.Thread) (ArrayItemMatchAnnotation, error)
func (ArrayItemMatchAnnotation) Indexes ¶
func (a ArrayItemMatchAnnotation) Indexes(leftArray *yamlmeta.Array) ([]int, error)
func (ArrayItemMatchAnnotation) MatchNodes ¶
type AssertAnnotation ¶ added in v0.24.0
type AssertAnnotation struct {
// contains filtered or unexported fields
}
func NewAssertAnnotation ¶ added in v0.24.0
func NewAssertAnnotation(newNode template.EvaluationNode, thread *starlark.Thread) (AssertAnnotation, error)
func (AssertAnnotation) Check ¶ added in v0.24.0
func (a AssertAnnotation) Check(existingNode template.EvaluationNode) error
type Comparison ¶ added in v0.24.0
type Comparison struct{}
func (Comparison) Compare ¶ added in v0.24.0
func (b Comparison) Compare(left, right interface{}) (bool, string)
func (Comparison) CompareLeafs ¶ added in v0.24.0
func (b Comparison) CompareLeafs(left, right interface{}) (bool, string)
type DocumentMatchAnnotation ¶
type DocumentMatchAnnotation struct {
// contains filtered or unexported fields
}
func NewDocumentMatchAnnotation ¶
func NewDocumentMatchAnnotation(newDoc *yamlmeta.Document, defaults MatchChildDefaultsAnnotation, exact bool, thread *starlark.Thread) (DocumentMatchAnnotation, error)
func (DocumentMatchAnnotation) IndexTuples ¶
func (a DocumentMatchAnnotation) IndexTuples(leftDocSets []*yamlmeta.DocumentSet) ([][]int, error)
func (DocumentMatchAnnotation) MatchNodes ¶
func (a DocumentMatchAnnotation) MatchNodes(leftDocSets []*yamlmeta.DocumentSet) ([][]int, []*filepos.Position, error)
type InsertAnnotation ¶
type InsertAnnotation struct {
// contains filtered or unexported fields
}
func NewInsertAnnotation ¶
func NewInsertAnnotation(newItem template.EvaluationNode, thread *starlark.Thread) (InsertAnnotation, error)
NewInsertAnnotation returns a new InsertAnnotation for the given node and with the given Starlark thread
func (InsertAnnotation) IsAfter ¶
func (a InsertAnnotation) IsAfter() bool
func (InsertAnnotation) IsBefore ¶
func (a InsertAnnotation) IsBefore() bool
func (InsertAnnotation) Value ¶ added in v0.48.0
func (a InsertAnnotation) Value(existingNode template.EvaluationNode) (interface{}, error)
Value returns the new value for the given, existing node. If `via` is not provided, the value of the existing node is returned, otherwise the result of `via`.
type MapItemMatchAnnotation ¶
type MapItemMatchAnnotation struct {
// contains filtered or unexported fields
}
func NewMapItemMatchAnnotation ¶
func NewMapItemMatchAnnotation(newItem *yamlmeta.MapItem, defaults MatchChildDefaultsAnnotation, thread *starlark.Thread) (MapItemMatchAnnotation, error)
func (MapItemMatchAnnotation) Indexes ¶ added in v0.48.0
func (a MapItemMatchAnnotation) Indexes(leftMap *yamlmeta.Map) ([]int, error)
func (MapItemMatchAnnotation) MatchNodes ¶ added in v0.48.0
type MatchAnnotationExpectsKwarg ¶
type MatchAnnotationExpectsKwarg struct {
// contains filtered or unexported fields
}
func (MatchAnnotationExpectsKwarg) Check ¶
func (a MatchAnnotationExpectsKwarg) Check(matches []*filepos.Position) error
func (*MatchAnnotationExpectsKwarg) FillInDefaults ¶ added in v0.20.0
func (a *MatchAnnotationExpectsKwarg) FillInDefaults(defaults MatchChildDefaultsAnnotation)
type MatchAnnotationNumMatchError ¶ added in v0.48.0
type MatchAnnotationNumMatchError struct {
// contains filtered or unexported fields
}
func (MatchAnnotationNumMatchError) Error ¶ added in v0.48.0
func (e MatchAnnotationNumMatchError) Error() string
type MatchChildDefaultsAnnotation ¶ added in v0.20.0
type MatchChildDefaultsAnnotation struct {
// contains filtered or unexported fields
}
func NewEmptyMatchChildDefaultsAnnotation ¶ added in v0.20.0
func NewEmptyMatchChildDefaultsAnnotation() MatchChildDefaultsAnnotation
func NewMatchChildDefaultsAnnotation ¶ added in v0.20.0
func NewMatchChildDefaultsAnnotation(node template.EvaluationNode, parentMatchChildDefaults MatchChildDefaultsAnnotation) (MatchChildDefaultsAnnotation, error)
type ReplaceAnnotation ¶ added in v0.19.0
type ReplaceAnnotation struct {
// contains filtered or unexported fields
}
func NewReplaceAnnotation ¶ added in v0.19.0
func NewReplaceAnnotation(newNode template.EvaluationNode, thread *starlark.Thread) (ReplaceAnnotation, error)
func (ReplaceAnnotation) OrAdd ¶ added in v0.48.0
func (a ReplaceAnnotation) OrAdd() bool
func (ReplaceAnnotation) Value ¶ added in v0.19.0
func (a ReplaceAnnotation) Value(existingNode template.EvaluationNode) (interface{}, error)
Source Files ¶
- annotations.go
- api.go
- array.go
- array_item_match_annotation.go
- assert_annotation.go
- compare.go
- doc.go
- document.go
- document_match_annotation.go
- insert_annotation.go
- map.go
- map_item_match_annotation.go
- match_annotation_expects_kwarg.go
- match_child_defaults_annotation.go
- op.go
- plain_merge.go
- replace_annotation.go
Click to show internal directories.
Click to hide internal directories.