Documentation
¶
Overview ¶
Package mapper renders mapping configurations with Go templates and helper functions. It is used to transform arbitrary input data into typed structures.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExtraMappedData ¶
type ExtraMappedData struct {
APIVersion string
ItemFamily string
Identifier string
Spec map[string]any
}
ExtraMappedData wraps the identifier and rendered spec produced by a Mapper.
type ExtraMapping ¶
type ExtraMapping struct {
APIVersion string
ItemFamily string
DeletePolicy string
CreateIfTemplate *template.Template
IDTemplate *template.Template
BodyTemplate *template.Template
}
ExtraMapping defines a pre-compiled template for an extra item.
type MappedData ¶
MappedData wraps the identifier and rendered spec produced by a Mapper.
type Mapper ¶
type Mapper interface {
// ApplyTemplates applies the mapper templates to the given input data and returns the mapped output.
ApplyTemplates(input map[string]any, parentItemInfo ParentItemInfo) (output MappedData, extra []ExtraMappedData, err error)
// ApplyIdentifierTemplate applies only the identifier template to the given input data and returns
ApplyIdentifierTemplate(data map[string]any) (string, []ExtraMappedData, error)
}
Mapper renders input data into templated output structures. Implementations must provide an identifier template that yields a unique key per entity. Template strings are evaluated using Go's text/template engine.
type ParentItemInfo ¶
ParentItemInfo holds metadata about the parent item for relationship extra mappings.
type ParsingError ¶
type ParsingError struct {
// contains filtered or unexported fields
}
ParsingError wraps failures that happen while compiling mapper templates.
func NewParsingError ¶
func NewParsingError(err error) *ParsingError
NewParsingError builds a ParsingError from the underlying parsing error chain.
func (*ParsingError) Error ¶
func (e *ParsingError) Error() string
func (*ParsingError) Is ¶
func (e *ParsingError) Is(target error) bool
func (*ParsingError) Unwrap ¶
func (e *ParsingError) Unwrap() error