diff

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	Context   string       `json:"context"`
	Diff      []Difference `json:"diff"`
	Kind      Kind
	Operation Operation
	// contains filtered or unexported fields
}

Change encapsulates all differences between two apps and carries the information about the context those apps exist in the app tree.

func (Change) Filter

func (c Change) Filter(f func(d Difference) bool) (ret Change)

Filter filters the differences of the Change with the return value of the given function

func (Change) FilterKind

func (c Change) FilterKind(kind Kind) Change

FilterKind filters the diffs of the change by its kind.

func (Change) ForEach

func (c Change) ForEach(f DifferenceOperation) error

ForEach applies the function for each change in the changelog

Errors are concatenated

type ChangeFilter

type ChangeFilter func(c Change) bool

ChangeFilter filters changes

type ChangeOperation

type ChangeOperation func(c Change) error

ChangeOperation applies an operation in a change and returns an error

type ChangeReaction

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

ChangeReaction is a struct that holds a filter and an operation to be applied on a Changelog. The filter determines which changess will be applied to and the operation defines what will be applied to each change.

func NewChangeKindReaction

func NewChangeKindReaction(kind Kind, apply func(c Change) error) ChangeReaction

NewChangeKindReaction creates a ChangeOperation that filters per type.

See ChangeOperation

func NewChangeReaction

func NewChangeReaction(filter ChangeFilter, apply ChangeOperation) ChangeReaction

NewChangeReaction creates a ChangeOperation for the given filter and apply function

See ChangeOperation

type Changelog

type Changelog []Change

Changelog log of all changes between two app trees.

func Diff

func Diff(appOrig *meta.App, appCurr *meta.App) (Changelog, error)

Diff returns the changelog between two app trees.

func (Changelog) FilterDiffs

func (c Changelog) FilterDiffs(comp DifferenceFilter) Changelog

FilterDiffs filters the entries in the changelog by an arbitrary function

func (Changelog) FilterDiffsByKind

func (c Changelog) FilterDiffsByKind(kind Kind) Changelog

FilterDiffsByKind filters the changelog by changes of a spefific kind or combination of kinds. To use a combination, just bitwise or the different kinds, so, if you want the changes on channels and apps, use

c.FilterDiffsByKind(AppKind|ChannelKind)

func (Changelog) ForEach

func (c Changelog) ForEach(f func(c Change) error) error

ForEach applies a function on each change of the changelog

func (Changelog) ForEachDiffFiltered

func (c Changelog) ForEachDiffFiltered(operations ...DifferenceReaction) error

ForEachDiffFiltered applies each operation on the diffs contained in the changelog.

The operations are applied only if the filters defined on them return true, and every filter is applied on each diff in the changelog.

Errors are concatenated

func (Changelog) ForEachFiltered

func (c Changelog) ForEachFiltered(operations ...ChangeReaction) error

ForEachFiltered applies each operation on the changes contained in the changelog.

The operations are applied only if the filters defined on them return true, and every filter is applied on each change in the changelog.

Errors are concatenated.

func (Changelog) Print

func (cl Changelog) Print(out io.Writer)

Print is an auxiliar method used for displaying a Changelog

type Difference

type Difference struct {
	Field     string `json:"field"`
	From      string `json:"from"`
	To        string `json:"to"`
	Kind      Kind
	Name      string
	Operation Operation
}

Difference is the most basic diff structure, it represents a difference between two apps. The object carries information abaout what field differs from one app to another, the value of that field on the original app and the value of that field on the current app.

type DifferenceFilter

type DifferenceFilter func(scope string, d Difference) bool

DifferenceFilter filters differnces

type DifferenceOperation

type DifferenceOperation func(scope string, d Difference) error

DifferenceOperation applies a function in a difference and returns its error

type DifferenceReaction

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

DifferenceReaction is a struct that holds a filter and an operation to be applied on a Changelog. The filter determines which differences will be applied to and the operation defines what will be applied to each difference.

func NewDifferenceKindReaction

func NewDifferenceKindReaction(kind Kind, apply DifferenceOperation) DifferenceReaction

NewDifferenceKindReaction creates a DifferenceOperation that filters per type.

See DifferenceOperation

func NewDifferenceReaction

func NewDifferenceReaction(filter DifferenceFilter, apply DifferenceOperation) DifferenceReaction

NewDifferenceReaction creates a DifferenceOperation for the given filter and apply function

See DifferenceOperation

type Kind

type Kind int

Kind represents a kind of difference between two structures

const (
	AppKind Kind = 1 << iota
	NodeKind
	MetaKind
	ChannelKind
	ChannelTypeKind
	BoundaryKind
	FieldKind
	AnnotationKind
	AliasKind
	EnvironmentKind
)

Kinds of diff

type Operation

type Operation int

Operation represents an operation that has been applied in a diff

const (
	Delete Operation = 1 << iota
	Update
	Create
)

The kinds of operation

Jump to

Keyboard shortcuts

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