drift

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package drift compares two scans and their maps: which facts and which conclusions were added, removed or changed. Facts are compared by kind and key, so a moved line is never drift; map items by their identity (a party by id, a link by service and recipe, a finding by rule and subject, so a new detail is a change).

Index

Constants

View Source
const SchemaID = "cernly.drift/v1"

SchemaID is the id every drift document is written with.

View Source
const SectionTransitive = "dependency_transitive"

SectionTransitive groups transitive dependencies apart from the direct ones.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	Change  string          `json:"change"`  // added, removed, changed
	Section string          `json:"section"` // fact kind, or map section (parties, links, stacks, ...)
	Key     string          `json:"key"`
	Before  json.RawMessage `json:"before,omitempty"`
	After   json.RawMessage `json:"after,omitempty"`
}

func (Change) Diff

func (c Change) Diff() string

Diff names what a changed item changed: each top-level field whose value differs, as field: old → new. Empty for an added or removed item.

type Drift

type Drift struct {
	Schema string   `json:"schema"`
	Repo   string   `json:"repo"`
	From   Ref      `json:"from"`
	To     Ref      `json:"to"`
	Facts  []Change `json:"facts"`
	Map    []Change `json:"map"`
}

func Compare

func Compare(a, b *fact.Scan, am, bm *rules.Map) *Drift

Compare returns what changed from a to b. Maps may be nil (facts only).

func Read

func Read(raw []byte) (*Drift, error)

Read parses a drift document written with SchemaID or the id before the rename. The result carries SchemaID, so writing it again uses the new id.

type DriftGroup

type DriftGroup struct {
	Section  string   `json:"section"`
	Label    string   `json:"label"`
	One      string   `json:"one"` // the label for a count of one ("1 data store")
	Added    int      `json:"added"`
	Removed  int      `json:"removed"`
	Changed  int      `json:"changed"`
	Examples []string `json:"examples"`
}

DriftGroup is one kind of fact in a drift, counted, with a few examples.

func Groups

func Groups(d *Drift) []DriftGroup

Groups counts a drift's fact changes per kind, in a fixed order, with up to four examples each.

func MapGroups

func MapGroups(d *Drift) []DriftGroup

MapGroups does the same for the map's changes, per map section.

type Ref

type Ref struct {
	Commit      string `json:"commit"`
	CommittedAt string `json:"committed_at"`
}

Jump to

Keyboard shortcuts

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