patch

package
v0.21.0-beta.11 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertPatchToObject

func ConvertPatchToObject(fromMap map[string]interface{}, toObj client.Object) error

func JoinPath

func JoinPath(root, next string) string

func Value

func Value[T any](path string, patches ...Patch) (T, bool)

Types

type Patch

type Patch map[string]interface{}

Patch helps with navigating generic map[string]interface{} which is used by unstructured objects. It's called patch, because we only operate on patches from virtual to host and back and these functions help to keep it as generic as possible.

func CalculateMergePatch

func CalculateMergePatch(beforeObject, afterObject client.Object) (Patch, error)

func ConvertObjectToPatch

func ConvertObjectToPatch(obj runtime.Object) (Patch, error)

func (Patch) Apply

func (p Patch) Apply(obj client.Object) error

func (Patch) Clear

func (p Patch) Clear()

func (Patch) DeepCopy

func (p Patch) DeepCopy() Patch

func (Patch) Delete

func (p Patch) Delete(path string)

func (Patch) DeleteAllExcept

func (p Patch) DeleteAllExcept(path string, except ...string)

func (Patch) Has

func (p Patch) Has(path string) bool

func (Patch) IsEmpty

func (p Patch) IsEmpty() bool

func (Patch) MustTranslate

func (p Patch) MustTranslate(path string, translate func(path string, val interface{}) (interface{}, error))

func (Patch) Set

func (p Patch) Set(path string, value interface{})

Set sets a value and will create objects along the way. Wildcard paths are not supported here.

func (Patch) String

func (p Patch) String(path string) (string, bool)

func (Patch) Translate

func (p Patch) Translate(path string, translate func(path string, val interface{}) (interface{}, error)) error

Translate changes existing (!) values on the given path. If you want to set a value, use the set function instead.

func (Patch) Value

func (p Patch) Value(path string) (interface{}, bool)

type PathValue

type PathValue struct {
	Parent *PathValue

	Value interface{}

	Index int
	Key   string

	Path string
}

Jump to

Keyboard shortcuts

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