patch

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2018 License: MIT Imports: 7 Imported by: 332

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AfterLastIndexToken

type AfterLastIndexToken struct{}

type AfterModifier

type AfterModifier struct{}

type ArrayIndex

type ArrayIndex struct {
	Index     int
	Modifiers []Modifier
	Array     []interface{}
	Path      Pointer
}

func (ArrayIndex) Concrete

func (i ArrayIndex) Concrete() (int, error)

type ArrayInsertion

type ArrayInsertion struct {
	Index     int
	Modifiers []Modifier
	Array     []interface{}
	Path      Pointer
}

func (ArrayInsertion) Concrete

func (i ArrayInsertion) Concrete() (ArrayInsertionIndex, error)

type ArrayInsertionIndex

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

func (ArrayInsertionIndex) Update

func (i ArrayInsertionIndex) Update(array []interface{}, obj interface{}) []interface{}

type BeforeModifier

type BeforeModifier struct{}

type DescriptiveOp

type DescriptiveOp struct {
	Op       Op
	ErrorMsg string
}

func (DescriptiveOp) Apply

func (op DescriptiveOp) Apply(doc interface{}) (interface{}, error)

type Diff added in v0.2.0

type Diff struct {
	Left      interface{}
	Right     interface{}
	Unchecked bool
}

func (Diff) Calculate added in v0.2.0

func (d Diff) Calculate() Ops

type ErrOp

type ErrOp struct {
	Err error
}

func (ErrOp) Apply

func (op ErrOp) Apply(_ interface{}) (interface{}, error)

type FindOp

type FindOp struct {
	Path Pointer
}

func (FindOp) Apply

func (op FindOp) Apply(doc interface{}) (interface{}, error)

type IndexToken

type IndexToken struct {
	Index     int
	Modifiers []Modifier
}

type KeyToken

type KeyToken struct {
	Key      string
	Optional bool
}

type MatchingIndexToken

type MatchingIndexToken struct {
	Key       string
	Value     string
	Optional  bool
	Modifiers []Modifier
}

type Modifier

type Modifier interface {
	// contains filtered or unexported methods
}

type NextModifier

type NextModifier struct{}

type Op

type Op interface {
	Apply(interface{}) (interface{}, error)
}

type OpDefinition

type OpDefinition struct {
	Type   string       `json:",omitempty" yaml:",omitempty"`
	Path   *string      `json:",omitempty" yaml:",omitempty"`
	Value  *interface{} `json:",omitempty" yaml:",omitempty"`
	Absent *bool        `json:",omitempty" yaml:",omitempty"`
	Error  *string      `json:",omitempty" yaml:",omitempty"`
}

OpDefinition struct is useful for JSON and YAML unmarshaling

func NewOpDefinitionsFromOps added in v0.2.0

func NewOpDefinitionsFromOps(ops Ops) ([]OpDefinition, error)

type OpMismatchTypeErr added in v0.2.0

type OpMismatchTypeErr struct {
	Type_ string
	Path  Pointer
	Obj   interface{}
}

func NewOpArrayMismatchTypeErr added in v0.2.0

func NewOpArrayMismatchTypeErr(path Pointer, obj interface{}) OpMismatchTypeErr

func NewOpMapMismatchTypeErr added in v0.2.0

func NewOpMapMismatchTypeErr(path Pointer, obj interface{}) OpMismatchTypeErr

func (OpMismatchTypeErr) Error added in v0.2.0

func (e OpMismatchTypeErr) Error() string

type OpMissingIndexErr

type OpMissingIndexErr struct {
	Idx  int
	Obj  []interface{}
	Path Pointer
}

func (OpMissingIndexErr) Error

func (e OpMissingIndexErr) Error() string

type OpMissingMapKeyErr added in v0.2.0

type OpMissingMapKeyErr struct {
	Key  string
	Path Pointer
	Obj  map[interface{}]interface{}
}

func (OpMissingMapKeyErr) Error added in v0.2.0

func (e OpMissingMapKeyErr) Error() string

type OpMultipleMatchingIndexErr added in v0.2.0

type OpMultipleMatchingIndexErr struct {
	Path Pointer
	Idxs []int
}

func (OpMultipleMatchingIndexErr) Error added in v0.2.0

type OpUnexpectedTokenErr added in v0.2.0

type OpUnexpectedTokenErr struct {
	Token Token
	Path  Pointer
}

func (OpUnexpectedTokenErr) Error added in v0.2.0

func (e OpUnexpectedTokenErr) Error() string

type Ops

type Ops []Op

func NewOpsFromDefinitions

func NewOpsFromDefinitions(opDefs []OpDefinition) (Ops, error)

func (Ops) Apply

func (ops Ops) Apply(doc interface{}) (interface{}, error)

type Pointer

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

More or less based on https://tools.ietf.org/html/rfc6901

func MustNewPointerFromString

func MustNewPointerFromString(str string) Pointer

func NewPointer

func NewPointer(tokens []Token) Pointer

func NewPointerFromString

func NewPointerFromString(str string) (Pointer, error)

func (Pointer) IsSet

func (p Pointer) IsSet() bool

func (Pointer) String

func (p Pointer) String() string

func (Pointer) Tokens

func (p Pointer) Tokens() []Token

func (*Pointer) UnmarshalFlag

func (p *Pointer) UnmarshalFlag(data string) error

UnmarshalFlag satisfies go-flags flag interface

type PrevModifier

type PrevModifier struct{}

type RemoveOp

type RemoveOp struct {
	Path Pointer
}

func (RemoveOp) Apply

func (op RemoveOp) Apply(doc interface{}) (interface{}, error)

type ReplaceOp

type ReplaceOp struct {
	Path  Pointer
	Value interface{} // will be cloned using yaml library
}

func (ReplaceOp) Apply

func (op ReplaceOp) Apply(doc interface{}) (interface{}, error)

type RootToken

type RootToken struct{}

type TestOp added in v0.2.0

type TestOp struct {
	Path   Pointer
	Value  interface{}
	Absent bool
}

func (TestOp) Apply added in v0.2.0

func (op TestOp) Apply(doc interface{}) (interface{}, error)

type Token

type Token interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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