strategicpatch

package
v1.60.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTagStructTypeOrDie

func GetTagStructTypeOrDie(dataStruct interface{}) reflect.Type

func StrategicMergePatch

func StrategicMergePatch(original, patch []byte, dataStruct interface{}) ([]byte, error)

StrategicMergePatch applies a strategic merge patch. The patch and the original document must be json encoded content. A patch can be created from an original and a modified document by calling CreateStrategicMergePatch.

func StrategicMergePatchUsingLookupPatchMeta

func StrategicMergePatchUsingLookupPatchMeta(original, patch []byte, schema LookupPatchMeta) ([]byte, error)

Types

type FieldNotFoundError

type FieldNotFoundError struct {
	Path  string
	Field string
}

func (FieldNotFoundError) Error

func (e FieldNotFoundError) Error() string

type InvalidTypeError

type InvalidTypeError struct {
	Path     string
	Expected string
	Actual   string
}

func (InvalidTypeError) Error

func (e InvalidTypeError) Error() string

type JSONMap

type JSONMap map[string]interface{}

JSONMap is a representations of JSON object encoded as map[string]interface{} where the children can be either map[string]interface{}, []interface{} or primitive type). Operating on JSONMap representation is much faster as it doesn't require any json marshaling and/or unmarshaling operations.

func MergeStrategicMergeMapPatchUsingLookupPatchMeta

func MergeStrategicMergeMapPatchUsingLookupPatchMeta(schema LookupPatchMeta, patches ...JSONMap) (JSONMap, error)

MergeStrategicMergeMapPatchUsingLookupPatchMeta merges strategic merge patches retaining `null` fields and parallel lists. If 2 patches change the same fields and the latter one will override the former one. If you don't want that happen, you need to run func MergingMapsHaveConflicts before merging these patches. Applying the resulting merged merge patch to a JSONMap yields the same as merging each strategic merge patch to the JSONMap in succession.

func StrategicMergeMapPatch

func StrategicMergeMapPatch(original, patch JSONMap, dataStruct interface{}) (JSONMap, error)

StrategicMergeMapPatch applies a strategic merge patch. The original and patch documents must be JSONMap. A patch can be created from an original and modified document by calling CreateTwoWayMergeMapPatch. Warning: the original and patch JSONMap objects are mutated by this function and should not be reused.

func StrategicMergeMapPatchUsingLookupPatchMeta

func StrategicMergeMapPatchUsingLookupPatchMeta(original, patch JSONMap, schema LookupPatchMeta) (JSONMap, error)

type LookupPatchMeta

type LookupPatchMeta interface {
	// LookupPatchMetadataForStruct gets subschema and the patch metadata (e.g. patch strategy and merge key) for map.
	LookupPatchMetadataForStruct(key string) (LookupPatchMeta, PatchMeta, error)
	// LookupPatchMetadataForSlice get subschema and the patch metadata for slice.
	LookupPatchMetadataForSlice(key string) (LookupPatchMeta, PatchMeta, error)
	// Get the type name of the field
	Name() string
}

type LookupPatchMetaError

type LookupPatchMetaError struct {
	Path string
	Err  error
}

func (LookupPatchMetaError) Error

func (e LookupPatchMetaError) Error() string

type MergeOptions

type MergeOptions struct {
	// MergeParallelList indicates if we are merging the parallel list.
	// We don't merge parallel list when calling mergeMap() in CreateThreeWayMergePatch()
	// which is called client-side.
	// We merge parallel list iff when calling mergeMap() in StrategicMergeMapPatch()
	// which is called server-side
	MergeParallelList bool
	// IgnoreUnmatchedNulls indicates if we should process the unmatched nulls.
	IgnoreUnmatchedNulls bool
}

type PatchMeta

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

func (*PatchMeta) GetPatchMergeKey

func (pm *PatchMeta) GetPatchMergeKey() string

func (*PatchMeta) GetPatchStrategies

func (pm *PatchMeta) GetPatchStrategies() []string

func (*PatchMeta) SetPatchMergeKey

func (pm *PatchMeta) SetPatchMergeKey(pmk string)

func (*PatchMeta) SetPatchStrategies

func (pm *PatchMeta) SetPatchStrategies(ps []string)

type PatchMetaFromStruct

type PatchMetaFromStruct struct {
	T reflect.Type
}

func NewPatchMetaFromStruct

func NewPatchMetaFromStruct(dataStruct interface{}) (PatchMetaFromStruct, error)

func (PatchMetaFromStruct) LookupPatchMetadataForSlice

func (s PatchMetaFromStruct) LookupPatchMetadataForSlice(key string) (LookupPatchMeta, PatchMeta, error)

func (PatchMetaFromStruct) LookupPatchMetadataForStruct

func (s PatchMetaFromStruct) LookupPatchMetadataForStruct(key string) (LookupPatchMeta, PatchMeta, error)

func (PatchMetaFromStruct) Name

func (s PatchMetaFromStruct) Name() string

Directories

Path Synopsis
internal
json
Package json is forked from the Go standard library to enable us to find the field of a struct that a given JSON key maps to.
Package json is forked from the Go standard library to enable us to find the field of a struct that a given JSON key maps to.

Jump to

Keyboard shortcuts

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