Version: v1.0.0 Latest Latest

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

Go to latest
Published: Jun 18, 2015 License: Apache-2.0 Imports: 6 Imported by: 0




This section is empty.


View Source
var ErrConflict = fmt.Errorf("changes are in conflict")
View Source
var ErrPreconditionFailed = fmt.Errorf("a precondition failed")


func IsConflicting

func IsConflicting(err error) bool

IsConflicting returns true if the provided error indicates a conflict exists between the original changes and the applied changes.

func IsPreconditionFailed

func IsPreconditionFailed(err error) bool

IsPreconditionFailed returns true if the provided error indicates a Delta precondition did not succeed.


type Delta

type Delta struct {
	// contains filtered or unexported fields

Delta represents a change between two JSON documents.

func NewDelta

func NewDelta(from, to []byte) (*Delta, error)

NewDelta accepts two JSON or YAML documents and calculates the difference between them. It returns a Delta object which can be used to resolve conflicts against a third version with a common parent, or an error if either document is in error.

func (*Delta) AddPreconditions

func (d *Delta) AddPreconditions(fns ...PreconditionFunc)

AddPreconditions adds precondition checks to a change which must be satisfied before an Apply is considered successful. If a precondition returns false, the Apply is failed with ErrPreconditionFailed.

func (*Delta) Apply

func (d *Delta) Apply(latest []byte) ([]byte, error)

Apply attempts to apply the changes described by Delta onto latest, returning an error if the changes cannot be applied cleanly. IsConflicting will be true if the changes overlap, otherwise a generic error will be returned.

type PreconditionFunc

type PreconditionFunc func(interface{}) bool

PreconditionFunc is a test to verify that an incompatible change has occurred before an Apply can be successful.

func RequireKeyUnchanged

func RequireKeyUnchanged(key string) PreconditionFunc

RequireKeyUnchanged creates a precondition function that fails if the provided key is present in the diff (indicating its value has changed).

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL