Documentation
¶
Index ¶
- func GetTagStructTypeOrDie(dataStruct interface{}) reflect.Type
- func StrategicMergePatch(original, patch []byte, dataStruct interface{}) ([]byte, error)
- func StrategicMergePatchUsingLookupPatchMeta(original, patch []byte, schema LookupPatchMeta) ([]byte, error)
- type FieldNotFoundError
- type InvalidTypeError
- type JSONMap
- func MergeStrategicMergeMapPatchUsingLookupPatchMeta(schema LookupPatchMeta, patches ...JSONMap) (JSONMap, error)
- func StrategicMergeMapPatch(original, patch JSONMap, dataStruct interface{}) (JSONMap, error)
- func StrategicMergeMapPatchUsingLookupPatchMeta(original, patch JSONMap, schema LookupPatchMeta) (JSONMap, error)
- type LookupPatchMeta
- type LookupPatchMetaError
- type MergeOptions
- type PatchMeta
- type PatchMetaFromStruct
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTagStructTypeOrDie ¶
func StrategicMergePatch ¶
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 ¶
func (FieldNotFoundError) Error ¶
func (e FieldNotFoundError) Error() string
type InvalidTypeError ¶
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 ¶
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 ¶
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 (*PatchMeta) GetPatchStrategies ¶
func (*PatchMeta) SetPatchMergeKey ¶
func (*PatchMeta) SetPatchStrategies ¶
type PatchMetaFromStruct ¶
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