transform

package
v0.5.6-rc.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClusterTmplFuncs added in v0.5.3

func GetClusterTmplFuncs(cluster string) (template.FuncMap, bool)

func Patch

func Patch(original interface{}, patchText string) (interface{}, error)

Patch function applies a JSON patch to the original data structure.

func Register

func Register(tType string, transFunc TransformFunc)

Register function registers a transformation function with the given type.

func RegisterClusterTmplFunc added in v0.5.3

func RegisterClusterTmplFunc(cluster, funcName string, tmplFunc any) error

func Replace

func Replace(original interface{}, jsonString string) (interface{}, error)

Replace function replaces the original data structure with the new one derived from the JSON string.

Types

type TransformFunc

type TransformFunc func(original interface{}, transformText string) (target interface{}, err error)

TransformFunc is a type definition for transformation functions that take an original data structure and a transformation string, and return a transformed data structure and an error.

func GetTransformFunc

func GetTransformFunc(transformerType string) (TransformFunc, bool)

GetTransformFunc retrieves a registered transformation function by type.

type TransformFuncRegistry

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

TransformFuncRegistry is a struct that holds a map of transformation functions.

func NewRegistry

func NewRegistry() *TransformFuncRegistry

NewRegistry creates and returns a new instance of TransformFuncRegistry.

func (*TransformFuncRegistry) Get

func (r *TransformFuncRegistry) Get(transformerType string) (transFunc TransformFunc, found bool)

Get method of TransformFuncRegistry retrieves a registered transformation function by type.

func (*TransformFuncRegistry) Register

func (r *TransformFuncRegistry) Register(tType string, transFunc TransformFunc)

Register method of TransformFuncRegistry registers a transformation function with the given type.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL