Documentation
¶
Overview ¶
Package jmes implements the transform template using JMESPath templates.
Index ¶
- Variables
- func EvaluateObjectFieldMappingEntries(input map[string]FieldMappingEntryConfig, getEnvFunc goenvconf.GetEnvFunc) (map[string]FieldMappingEntry, error)
- func EvaluateObjectFieldMappingStringEntries(input map[string]FieldMappingEntryStringConfig, ...) (map[string]FieldMappingEntryString, error)
- type FieldMapping
- type FieldMappingConfig
- func (fm FieldMappingConfig) Equal(target FieldMappingConfig) bool
- func (fm FieldMappingConfig) Interface() FieldMappingConfigInterface
- func (fm FieldMappingConfig) IsZero() bool
- func (fm *FieldMappingConfig) UnmarshalJSON(b []byte) error
- func (fm *FieldMappingConfig) UnmarshalYAML(value *yaml.Node) error
- type FieldMappingConfigInterface
- type FieldMappingEntry
- type FieldMappingEntryConfig
- func (fm FieldMappingEntryConfig) Equal(target FieldMappingEntryConfig) bool
- func (fm FieldMappingEntryConfig) Evaluate(getEnvFunc goenvconf.GetEnvFunc) (FieldMapping, error)
- func (fm FieldMappingEntryConfig) EvaluateEntry(getEnvFunc goenvconf.GetEnvFunc) (FieldMappingEntry, error)
- func (fm FieldMappingEntryConfig) EvaluateEntryEnv() (FieldMappingEntry, error)
- func (fm FieldMappingEntryConfig) EvaluateEnv() (FieldMapping, error)
- func (fm FieldMappingEntryConfig) IsZero() bool
- func (FieldMappingEntryConfig) Type() FieldMappingType
- type FieldMappingEntryString
- func (fm FieldMappingEntryString) Equal(target FieldMappingEntryString) bool
- func (fm FieldMappingEntryString) Evaluate(data any) (any, error)
- func (fm FieldMappingEntryString) EvaluateString(data any) (*string, error)
- func (fm FieldMappingEntryString) IsZero() bool
- func (FieldMappingEntryString) Type() FieldMappingType
- type FieldMappingEntryStringConfig
- func (fm FieldMappingEntryStringConfig) Equal(target FieldMappingEntryStringConfig) bool
- func (fm FieldMappingEntryStringConfig) Evaluate(getEnvFunc goenvconf.GetEnvFunc) (FieldMapping, error)
- func (fm FieldMappingEntryStringConfig) EvaluateEnv() (FieldMapping, error)
- func (fm FieldMappingEntryStringConfig) EvaluateString(getEnvFunc goenvconf.GetEnvFunc) (FieldMappingEntryString, error)
- func (fm FieldMappingEntryStringConfig) IsZero() bool
- func (FieldMappingEntryStringConfig) Type() FieldMappingType
- type FieldMappingInterface
- type FieldMappingObject
- type FieldMappingObjectConfig
- func (fm FieldMappingObjectConfig) Equal(target FieldMappingObjectConfig) bool
- func (fm FieldMappingObjectConfig) Evaluate(getEnvFunc goenvconf.GetEnvFunc) (FieldMapping, error)
- func (fm FieldMappingObjectConfig) EvaluateEnv() (FieldMapping, error)
- func (fm FieldMappingObjectConfig) IsZero() bool
- func (FieldMappingObjectConfig) Type() FieldMappingType
- type FieldMappingType
- type JMESTemplateTransformer
- type JMESTransformerConfig
- func (jt JMESTransformerConfig) Equal(target JMESTransformerConfig) bool
- func (jt JMESTransformerConfig) IsZero() bool
- func (jt JMESTransformerConfig) MarshalJSON() ([]byte, error)
- func (jt JMESTransformerConfig) MarshalYAML() (any, error)
- func (JMESTransformerConfig) Type() transformtypes.TransformTemplateType
- func (jt JMESTransformerConfig) Validate() error
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnsupportedFieldMappingType = errors.New("unsupported field mapping type") ErrFieldMappingEntryMalformed = errors.New("field mapping entry is malformed") ErrFieldMappingEntryRequired = errors.New("field mapping entry must not be empty") ErrFieldMappingObjectRequired = errors.New("field mapping object must not be null") )
Functions ¶
func EvaluateObjectFieldMappingEntries ¶
func EvaluateObjectFieldMappingEntries( input map[string]FieldMappingEntryConfig, getEnvFunc goenvconf.GetEnvFunc, ) (map[string]FieldMappingEntry, error)
EvaluateObjectFieldMappingEntries validate and resolve the entry mapping fields of an object.
func EvaluateObjectFieldMappingStringEntries ¶
func EvaluateObjectFieldMappingStringEntries( input map[string]FieldMappingEntryStringConfig, getEnvFunc goenvconf.GetEnvFunc, ) (map[string]FieldMappingEntryString, error)
EvaluateObjectFieldMappingStringEntries validate and resolve the entry mapping for string fields of an object.
Types ¶
type FieldMapping ¶
type FieldMapping struct {
FieldMappingInterface
}
FieldMapping is a wrapper of a field mapping interface to evaluate data.
func NewFieldMapping ¶
func NewFieldMapping(inner FieldMappingInterface) FieldMapping
NewFieldMapping creates a new field mapping instance.
func (FieldMapping) Equal ¶
func (fm FieldMapping) Equal(target FieldMapping) bool
Equal checks if this instance equals the target value.
func (FieldMapping) Interface ¶
func (fm FieldMapping) Interface() FieldMappingInterface
Interface returns the inner field mapping interface.
func (FieldMapping) IsZero ¶
func (fm FieldMapping) IsZero() bool
IsZero checks if the field mapping is empty or zero-valued.
type FieldMappingConfig ¶
type FieldMappingConfig struct {
FieldMappingConfigInterface `yaml:",inline"`
}
FieldMappingConfig represents a generic field mapping config.
func NewFieldMappingConfig ¶
func NewFieldMappingConfig(inner FieldMappingConfigInterface) FieldMappingConfig
NewFieldMappingConfig creates a new FieldMappingConfig instance.
func (FieldMappingConfig) Equal ¶
func (fm FieldMappingConfig) Equal(target FieldMappingConfig) bool
Equal checks if this instance equals the target value.
func (FieldMappingConfig) Interface ¶
func (fm FieldMappingConfig) Interface() FieldMappingConfigInterface
Interface returns the underlying config interface.
func (FieldMappingConfig) IsZero ¶
func (fm FieldMappingConfig) IsZero() bool
IsZero checks if the config is empty.
func (*FieldMappingConfig) UnmarshalJSON ¶
func (fm *FieldMappingConfig) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
func (*FieldMappingConfig) UnmarshalYAML ¶
func (fm *FieldMappingConfig) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML implements the custom behavior for the yaml.Unmarshaler interface.
type FieldMappingConfigInterface ¶
type FieldMappingConfigInterface interface {
Type() FieldMappingType
Evaluate(getEnvFunc goenvconf.GetEnvFunc) (FieldMapping, error)
EvaluateEnv() (FieldMapping, error)
}
FieldMappingConfigInterface abstracts the interface of a field mapping config.
type FieldMappingEntry ¶
type FieldMappingEntry struct {
// Path is a JMESPath expression to find a value in the input data.
Path *string
// Default value to be used when no value is found when looking up the value using the path.
Default any
}
FieldMappingEntry is the entry to lookup field values with the specified JMES path.
func (FieldMappingEntry) Equal ¶
func (fm FieldMappingEntry) Equal(target FieldMappingEntry) bool
Equal checks if this instance equals the target value.
func (FieldMappingEntry) Evaluate ¶
func (fm FieldMappingEntry) Evaluate(data any) (any, error)
Evaluate validates and transforms data with the specified JMES path.
func (FieldMappingEntry) IsZero ¶
func (fm FieldMappingEntry) IsZero() bool
IsZero checks if the field mapping entry is empty (zero-valued).
func (FieldMappingEntry) Type ¶
func (FieldMappingEntry) Type() FieldMappingType
Type returns type of the field mapping entry.
type FieldMappingEntryConfig ¶
type FieldMappingEntryConfig struct {
// Path is a JMESPath expression to find a value in the input data.
Path *string `json:"path,omitempty" yaml:"path,omitempty" jsonschema:"description=JMESPath expression to find a value in the input data"`
// Default value to be used when no value is found when looking up the value using the path.
Default *goenvconf.EnvAny `json:"default,omitempty" yaml:"default,omitempty" jsonschema:"description=Default value to be used when no value is found"`
}
FieldMappingEntryConfig is the entry config to lookup field values with the specified JMES path.
func (FieldMappingEntryConfig) Equal ¶
func (fm FieldMappingEntryConfig) Equal(target FieldMappingEntryConfig) bool
Equal checks if this instance equals the target value.
func (FieldMappingEntryConfig) Evaluate ¶
func (fm FieldMappingEntryConfig) Evaluate(getEnvFunc goenvconf.GetEnvFunc) (FieldMapping, error)
Evaluate converts the config to the field mapping instance with a custom env loader.
func (FieldMappingEntryConfig) EvaluateEntry ¶
func (fm FieldMappingEntryConfig) EvaluateEntry( getEnvFunc goenvconf.GetEnvFunc, ) (FieldMappingEntry, error)
EvaluateEntry converts the config to the field mapping entry instance with a custom env loader.
func (FieldMappingEntryConfig) EvaluateEntryEnv ¶
func (fm FieldMappingEntryConfig) EvaluateEntryEnv() (FieldMappingEntry, error)
EvaluateEntryEnv converts the config to the field mapping entry instance.
func (FieldMappingEntryConfig) EvaluateEnv ¶
func (fm FieldMappingEntryConfig) EvaluateEnv() (FieldMapping, error)
EvaluateEnv converts the config to the field mapping instance with environment variables.
func (FieldMappingEntryConfig) IsZero ¶
func (fm FieldMappingEntryConfig) IsZero() bool
IsZero checks if the config is empty.
func (FieldMappingEntryConfig) Type ¶
func (FieldMappingEntryConfig) Type() FieldMappingType
Type returns the type of field mapping config.
type FieldMappingEntryString ¶
type FieldMappingEntryString struct {
// Path is a JMESPath expression to find a value in the input data.
Path *string
// Default value to be used when no value is found when looking up the value using the path.
Default *string
}
FieldMappingEntryString is the entry to lookup string values with the specified JMES path.
func (FieldMappingEntryString) Equal ¶
func (fm FieldMappingEntryString) Equal(target FieldMappingEntryString) bool
Equal checks if this instance equals the target value.
func (FieldMappingEntryString) Evaluate ¶
func (fm FieldMappingEntryString) Evaluate(data any) (any, error)
Evaluate validates and transforms data with the specified JMES path, returning any value.
func (FieldMappingEntryString) EvaluateString ¶
func (fm FieldMappingEntryString) EvaluateString(data any) (*string, error)
EvaluateString validates and transforms data with the specified JMES path, returning string value explicitly.
func (FieldMappingEntryString) IsZero ¶
func (fm FieldMappingEntryString) IsZero() bool
IsZero checks if the field mapping entry string is empty or zero-valued.
func (FieldMappingEntryString) Type ¶
func (FieldMappingEntryString) Type() FieldMappingType
Type returns type of the field mapping entry string.
type FieldMappingEntryStringConfig ¶
type FieldMappingEntryStringConfig struct {
// Path is a JMESPath expression to find a value in the input data.
Path *string `json:"path,omitempty" yaml:"path,omitempty"`
// Default value to be used when no value is found when looking up the value using the path.
Default *goenvconf.EnvString `json:"default,omitempty" yaml:"default,omitempty"`
}
FieldMappingEntryStringConfig is the entry config to lookup string values with the specified JMES path.
func (FieldMappingEntryStringConfig) Equal ¶
func (fm FieldMappingEntryStringConfig) Equal(target FieldMappingEntryStringConfig) bool
Equal checks if this instance equals the target value.
func (FieldMappingEntryStringConfig) Evaluate ¶
func (fm FieldMappingEntryStringConfig) Evaluate( getEnvFunc goenvconf.GetEnvFunc, ) (FieldMapping, error)
Evaluate converts the config to the field mapping instance.
func (FieldMappingEntryStringConfig) EvaluateEnv ¶
func (fm FieldMappingEntryStringConfig) EvaluateEnv() (FieldMapping, error)
EvaluateEnv converts the config to the field mapping instance with environment variables.
func (FieldMappingEntryStringConfig) EvaluateString ¶
func (fm FieldMappingEntryStringConfig) EvaluateString( getEnvFunc goenvconf.GetEnvFunc, ) (FieldMappingEntryString, error)
EvaluateString converts the config to the field mapping instance.
func (FieldMappingEntryStringConfig) IsZero ¶
func (fm FieldMappingEntryStringConfig) IsZero() bool
IsZero checks if the config is empty.
func (FieldMappingEntryStringConfig) Type ¶
func (FieldMappingEntryStringConfig) Type() FieldMappingType
Type returns the type of field mapping config.
type FieldMappingInterface ¶
type FieldMappingInterface interface {
goutils.IsZeroer
Type() FieldMappingType
Evaluate(data any) (any, error)
}
FieldMappingInterface abstracts a field mapping interface.
type FieldMappingObject ¶
type FieldMappingObject struct {
Properties map[string]FieldMapping `json:"properties" yaml:"properties"`
}
FieldMappingObject is the entry to lookup object values with the specified JMES path.
func (FieldMappingObject) Equal ¶
func (fm FieldMappingObject) Equal(target FieldMappingObject) bool
Equal checks if this instance equals the target value.
func (FieldMappingObject) Evaluate ¶
func (fm FieldMappingObject) Evaluate(data any) (any, error)
Evaluate validates and transforms data with the specified JMES path.
func (FieldMappingObject) IsZero ¶
func (fm FieldMappingObject) IsZero() bool
IsZero checks if the field mapping object is empty.
func (FieldMappingObject) Type ¶
func (FieldMappingObject) Type() FieldMappingType
Type returns type of the field mapping entry.
type FieldMappingObjectConfig ¶
type FieldMappingObjectConfig struct {
// Properties of the field mapping object.
Properties map[string]FieldMappingConfig `json:"properties" yaml:"properties"`
}
FieldMappingObjectConfig represents configurations for the object field mapping.
func (FieldMappingObjectConfig) Equal ¶
func (fm FieldMappingObjectConfig) Equal(target FieldMappingObjectConfig) bool
Equal checks if this instance equals the target value.
func (FieldMappingObjectConfig) Evaluate ¶
func (fm FieldMappingObjectConfig) Evaluate(getEnvFunc goenvconf.GetEnvFunc) (FieldMapping, error)
Evaluate converts the config to the field mapping instance.
func (FieldMappingObjectConfig) EvaluateEnv ¶
func (fm FieldMappingObjectConfig) EvaluateEnv() (FieldMapping, error)
EvaluateEnv converts the config to the field mapping instance with environment variables.
func (FieldMappingObjectConfig) IsZero ¶
func (fm FieldMappingObjectConfig) IsZero() bool
IsZero checks if the config is empty.
func (FieldMappingObjectConfig) Type ¶
func (FieldMappingObjectConfig) Type() FieldMappingType
Type returns the type of field mapping config.
type FieldMappingType ¶
type FieldMappingType string
FieldMappingType represents a field mapping type enum.
const ( FieldMappingTypeField FieldMappingType = "field" FieldMappingTypeObject FieldMappingType = "object" )
type JMESTemplateTransformer ¶
type JMESTemplateTransformer struct {
// contains filtered or unexported fields
}
JMESTemplateTransformer implements the transform template using JMESPath templates.
func NewJMESTemplateTransformer ¶
func NewJMESTemplateTransformer(template FieldMapping) *JMESTemplateTransformer
NewJMESTemplateTransformer creates a new JMESTemplateTransformer instance.
func (JMESTemplateTransformer) Equal ¶
func (jtt JMESTemplateTransformer) Equal(target JMESTemplateTransformer) bool
Equal checks if this instance equals the target value.
func (JMESTemplateTransformer) IsZero ¶
func (jtt JMESTemplateTransformer) IsZero() bool
IsZero checks if the JMESTemplateTransformer is empty (zero-valued).
func (JMESTemplateTransformer) Transform ¶
func (jtt JMESTemplateTransformer) Transform(data any) (any, error)
Transform processes and injects data into the template to transform data.
func (JMESTemplateTransformer) Type ¶
func (JMESTemplateTransformer) Type() transformtypes.TransformTemplateType
Type returns the transform template type of this instance.
type JMESTransformerConfig ¶
type JMESTransformerConfig struct {
Template FieldMappingConfig `json:"template" yaml:"template"`
}
JMESTransformerConfig represents configurations for the Go template transformer.
func (JMESTransformerConfig) Equal ¶
func (jt JMESTransformerConfig) Equal(target JMESTransformerConfig) bool
Equal checks if this instance equals the target value.
func (JMESTransformerConfig) IsZero ¶
func (jt JMESTransformerConfig) IsZero() bool
IsZero checks if the config is empty.
func (JMESTransformerConfig) MarshalJSON ¶
func (jt JMESTransformerConfig) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (JMESTransformerConfig) MarshalYAML ¶
func (jt JMESTransformerConfig) MarshalYAML() (any, error)
MarshalYAML implements the yaml.Marshaler interface.
func (JMESTransformerConfig) Type ¶
func (JMESTransformerConfig) Type() transformtypes.TransformTemplateType
Type returns type of the transformer.
func (JMESTransformerConfig) Validate ¶
func (jt JMESTransformerConfig) Validate() error
Validate checks if the config is valid.