transform

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Transformer

type Transformer interface {
	Transform(*map[string]interface{}) (interface{}, error)
}

Transformer is a configuration transformer.

func NewTransformer

func NewTransformer(transformers []map[tree.Path]TransformerFunc) Transformer

NewTransformer creates a new transformer with the given transformers.

type TransformerFunc

type TransformerFunc func(*map[string]interface{}, interface{}, tree.Path) (any, error)

TransformerFunc is a function that transforms a part of the configuration. It modifies the data to conform to the expected structure and returns the transformed data. It takes the root configuration, the data to transform and the current path in the tree.

func MapToNamedSliceTransformer

func MapToNamedSliceTransformer(name string) TransformerFunc

MapToNamedSliceTransformer converts a map of maps to a slice of maps and assigns the key to the "name" field.

func SpecConfigTransformer

func SpecConfigTransformer(specName string) TransformerFunc

SpecConfigTransformer converts a map to a map with a "type" field and a "params" field.

type TransformerImpl

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

TransformerImpl is the implementation of the Transformer interface.

func (TransformerImpl) Transform

func (t TransformerImpl) Transform(rawConfig *map[string]interface{}) (interface{}, error)

Transform applies the transformers to the configuration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳