transform

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(node, newNode *yaml.RNode) (err error)

Add adds the subset to the target at the path, appends to lists

func Delete

func Delete(node *yaml.RNode, filters []yaml.Filter, pathParts []PathPart, operandIdx int) (err error)

Deletes data at the path

func SetNodeAtPath

func SetNodeAtPath(rootNode *yaml.RNode, node *yaml.RNode, filters []yaml.Filter, pathParts []PathPart, finalItemIdx int) error

SetNodeAtPath injects the updated node into rootNode according to the specified path and final node type

func Update

func Update(node, newNode *yaml.RNode) (*yaml.RNode, error)

Updates existing data at the path, overwrites lists

Types

type ChangeType

type ChangeType string
const (
	ChangeTypeAdd    ChangeType = "add"
	ChangeTypeUpdate ChangeType = "update"
	ChangeTypeDelete ChangeType = "delete"
)

type PartType added in v0.14.0

type PartType int
const (
	PartTypeMap      PartType = iota // e.g., a in a.b
	PartTypeSequence                 // e.g., a in a[b=c]
	PartTypeScalar                   // e.g., b in a.b
	PartTypeSelector                 // e.g., [a=b]
	PartTypeIndex                    // e.g., [0]
)

type PathPart added in v0.14.0

type PathPart struct {
	Type  PartType
	Value string
}

func PathToParts added in v0.14.0

func PathToParts(path string) []PathPart

PathToParts converts the path string into a slice of pathParts

func ResolvePathWithFilters added in v0.14.0

func ResolvePathWithFilters(targetNode *yaml.RNode, path string) ([]PathPart, []yaml.Filter, error)

ResolvePathWithFilters converts a path to its individual parts which define the type of part along with the appropriate kyaml filters to apply to the path

type TransformTarget

type TransformTarget struct {
	RootNode *yaml.RNode
}

func CreateTransformTarget

func CreateTransformTarget(parent map[string]interface{}) (*TransformTarget, error)

func (*TransformTarget) ExecuteTransform

func (t *TransformTarget) ExecuteTransform(path string, cType ChangeType, value string, valueMap map[string]interface{}) (map[string]interface{}, error)

func (*TransformTarget) UpdateRootNode added in v0.14.0

func (t *TransformTarget) UpdateRootNode(node *yaml.RNode) (map[string]interface{}, error)

UpdateRootNode updates the root node of the transform target and returns the updated node as a map[string]interface{}

Jump to

Keyboard shortcuts

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