Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnsupportedDiffType occurs when an invalid diff type is used. ErrUnsupportedDiffType = errors.New("dashdiff: unsupported diff type") // ErrNilDiff occurs when two compared interfaces are identical. ErrNilDiff = errors.New("dashdiff: diff is nil") )
Functions ¶
This section is empty.
Types ¶
type BasicBlock ¶
type BasicBlock struct { Title string Old interface{} New interface{} Change ChangeType Changes []*BasicChange Summaries []*BasicSummary LineStart int LineEnd int }
A BasicBlock represents a top-level element in a basic diff.
type BasicChange ¶
type BasicChange struct { Key string Old interface{} New interface{} Change ChangeType LineStart int LineEnd int }
A BasicChange represents the change from an old to new value. There are many BasicChanges in a BasicBlock.
type BasicDiff ¶
type BasicDiff struct { LastIndent int Block *BasicBlock Change *BasicChange Summary *BasicSummary // contains filtered or unexported fields }
A BasicDiff holds the stateful values that are used when generating a basic diff from JSON tokens.
func (*BasicDiff) Basic ¶
func (b *BasicDiff) Basic(lines []*JSONLine) []*BasicBlock
Basic transforms a slice of JSONLines into a slice of BasicBlocks.
type BasicFormatter ¶
type BasicFormatter struct {
// contains filtered or unexported fields
}
func NewBasicFormatter ¶
func NewBasicFormatter(left interface{}) *BasicFormatter
type BasicSummary ¶
type BasicSummary struct { Key string Change ChangeType Count int LineStart int LineEnd int }
A BasicSummary represents the changes within a basic block that're too deep or verbose to be represented in the top-level BasicBlock element, or in the BasicChange. Instead of showing the values in this case, we simply print the key and count how many times the given change was applied to that element.
type ChangeType ¶
type ChangeType int
const ( ChangeNil ChangeType = iota ChangeAdded ChangeDeleted ChangeOld ChangeNew ChangeUnchanged )
type DiffTarget ¶
type DiffTarget struct { DashboardId int64 Version int UnsavedDashboard *simplejson.Json }
type JSONFormatter ¶
type JSONFormatter struct { Lines []*JSONLine // contains filtered or unexported fields }
func NewJSONFormatter ¶
func NewJSONFormatter(left interface{}) *JSONFormatter
type JSONLine ¶
type JSONLine struct { LineNum int `json:"line"` LeftLine int `json:"leftLine"` RightLine int `json:"rightLine"` Indent int `json:"indent"` Text string `json:"text"` Change ChangeType `json:"changeType"` Key string `json:"key"` Val interface{} `json:"value"` }
JSONLine contains the data required to render each line of the JSON diff and contains the data required to produce the tokens output in the basic diff.
type Options ¶
type Options struct { OrgId int64 Base DiffTarget New DiffTarget DiffType DiffType }