Documentation
¶
Index ¶
- Constants
- func DecodeJSONPatchOperation(v any) (patch.Operation, error)
- func IsNonExistentPathError(err error) bool
- func JSONPatchFromBytes(data []byte) (patch.Patch, error)
- func JSONPatchFromReader(r io.Reader) (patch.Patch, error)
- func JSONPatchFromString(in string) (patch.Patch, error)
- func MergeMap(dst, src map[string]any) map[string]any
- func ValidateHookValuesPatch(valuesPatch ValuesPatch, permittedRootKey string) error
- type ApplyPatchMode
- type Values
- type ValuesPatch
- func AppendValuesPatch(valuesPatches []ValuesPatch, newValuesPatch ValuesPatch) []ValuesPatch
- func CompactPatches(existedOperations []*utils.ValuesPatchOperation, ...) ValuesPatch
- func CompactValuesPatches(valuesPatches []ValuesPatch, newValuesPatch ValuesPatch) []ValuesPatch
- func EnabledFromValuesPatch(valuesPatch ValuesPatch) ValuesPatch
- func FilterValuesPatch(valuesPatch ValuesPatch, rootPath string) ValuesPatch
- func NewValuesPatch() *ValuesPatch
- func ValuesPatchFromBytes(data []byte) (*ValuesPatch, error)
- func ValuesPatchFromFile(filePath string) (*ValuesPatch, error)
Constants ¶
const ( NonExistentPathErrorMsg = "error in remove for path:" MissingPathErrorMsg = "remove operation does not apply: doc is missing path" )
Error messages to distinguish non-typed errors from the 'json-patch' library.
const (
GlobalValuesKey = "global"
)
Variables ¶
This section is empty.
Functions ¶
func IsNonExistentPathError ¶
func MergeMap ¶
MergeMap recursively merges the src and dst maps. Key conflicts are resolved by preferring src, or recursively descending, if both src and dst are maps.
func ValidateHookValuesPatch ¶
func ValidateHookValuesPatch(valuesPatch ValuesPatch, permittedRootKey string) error
Types ¶
type ApplyPatchMode ¶
type ApplyPatchMode string
const ( Strict ApplyPatchMode = "strict" IgnoreNonExistentPaths ApplyPatchMode = "ignore-non-existent-paths" )
type Values ¶
Values stores values for modules or hooks by name.
func ApplyValuesPatch ¶
func ApplyValuesPatch(values Values, valuesPatch ValuesPatch, mode ApplyPatchMode) (Values, bool, error)
ApplyValuesPatch uses patched jsonpatch library to make the behavior of ApplyIgnoreNonExistentPaths as fast as ApplyStrict. This function does not mutate input Values
type ValuesPatch ¶
type ValuesPatch struct {
Operations []*utils.ValuesPatchOperation
}
func AppendValuesPatch ¶
func AppendValuesPatch(valuesPatches []ValuesPatch, newValuesPatch ValuesPatch) []ValuesPatch
func CompactPatches ¶
func CompactPatches(existedOperations []*utils.ValuesPatchOperation, newOperations []*utils.ValuesPatchOperation) ValuesPatch
CompactPatches modifies an array of existed patch operations according to the new array of patch operations. The rule is: only last operation for the path should be stored.
func CompactValuesPatches ¶
func CompactValuesPatches(valuesPatches []ValuesPatch, newValuesPatch ValuesPatch) []ValuesPatch
func EnabledFromValuesPatch ¶
func EnabledFromValuesPatch(valuesPatch ValuesPatch) ValuesPatch
func FilterValuesPatch ¶
func FilterValuesPatch(valuesPatch ValuesPatch, rootPath string) ValuesPatch
func NewValuesPatch ¶
func NewValuesPatch() *ValuesPatch
func ValuesPatchFromBytes ¶
func ValuesPatchFromBytes(data []byte) (*ValuesPatch, error)
ValuesPatchFromBytes reads a JSON stream of json patches and single operations from bytes and returns a ValuesPatch with all json patch operations. TODO do we need a separate utils.ValuesPatchOperation type??
func ValuesPatchFromFile ¶
func ValuesPatchFromFile(filePath string) (*ValuesPatch, error)
func (*ValuesPatch) ApplyIgnoreNonExistentPaths ¶
func (p *ValuesPatch) ApplyIgnoreNonExistentPaths(doc []byte) ([]byte, error)
ApplyIgnoreNonExistentPaths calls jsonpatch.Apply to transform an input JSON document.
- errors from "remove" operations are ignored.
func (*ValuesPatch) ApplyStrict ¶
func (p *ValuesPatch) ApplyStrict(doc []byte) ([]byte, error)
ApplyStrict calls jsonpatch.Apply to transform a JSON document according to the patch.
- "remove" operation errors are not ignored. - absent paths are not ignored.
func (*ValuesPatch) MergeOperations ¶
func (p *ValuesPatch) MergeOperations(src *ValuesPatch)
func (*ValuesPatch) ToJSONPatch ¶
func (p *ValuesPatch) ToJSONPatch() (patch.Patch, error)
ToJSONPatch returns a jsonpatch.Patch with all operations.