patch

package
v1.3.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PatchReplaceOp = "replace"
	PatchTestOp    = "test"
	PatchAddOp     = "add"
	PatchRemoveOp  = "remove"
)

Variables

This section is empty.

Functions

func EscapeJSONPointer

func EscapeJSONPointer(ptr string) string

func GeneratePatchPayload

func GeneratePatchPayload(patches ...PatchOperation) ([]byte, error)

func GenerateTestReplacePatch

func GenerateTestReplacePatch(path string, oldValue, newValue interface{}) ([]byte, error)

Types

type PatchOperation

type PatchOperation struct {
	Op    string      `json:"op"`
	Path  string      `json:"path"`
	Value interface{} `json:"value"`
}

func UnmarshalPatch

func UnmarshalPatch(patch []byte) ([]PatchOperation, error)

func (*PatchOperation) MarshalJSON added in v1.3.0

func (p *PatchOperation) MarshalJSON() ([]byte, error)

type PatchOption added in v1.3.0

type PatchOption func(patches *PatchSet)

func WithAdd added in v1.3.0

func WithAdd(path string, value interface{}) PatchOption

func WithRemove added in v1.3.0

func WithRemove(path string) PatchOption

func WithReplace added in v1.3.0

func WithReplace(path string, value interface{}) PatchOption

func WithTest added in v1.3.0

func WithTest(path string, value interface{}) PatchOption

type PatchSet added in v1.3.0

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

func New added in v1.3.0

func New(opts ...PatchOption) *PatchSet

func (*PatchSet) AddOption added in v1.3.0

func (p *PatchSet) AddOption(opts ...PatchOption)

func (*PatchSet) GeneratePayload added in v1.3.0

func (p *PatchSet) GeneratePayload() ([]byte, error)

func (*PatchSet) IsEmpty added in v1.3.0

func (p *PatchSet) IsEmpty() bool

Jump to

Keyboard shortcuts

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