sync

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 7 Imported by: ? modules, 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

Index

Constants

View Source
const (
	OpCreate = "create"
	OpUpdate = "update"
	OpDelete = "delete"
	OpNoop   = "noop"
)
View Source
const DefaultPruneThreshold = 0.2

Variables

This section is empty.

Functions

func CheckSafety

func CheckSafety(plan *Plan, liveCount int, desiredCount int, pruneThreshold float64, minEntities ...int) error

CheckSafety validates a plan against safety guards. minEntities > 0 prevents deleting all records (e.g. environments/teams must keep ≥1).

func EntityName

func EntityName(c Change) string

func FormatPlan

func FormatPlan(w io.Writer, plan *Plan)

func PlanToJSON

func PlanToJSON(plan *Plan) ([]byte, error)

PlanToJSON serializes a Plan as indented JSON bytes.

func SavePlan

func SavePlan(plan *Plan, path string) error

Types

type Applier

type Applier struct {
	BulkUpsert func(ctx context.Context, catalogID string, ents []catalog.DesiredEntity) error
	BulkDelete func(ctx context.Context, catalogID string, externalIDs []string) error
}

func (*Applier) Apply

func (a *Applier) Apply(ctx context.Context, plan *Plan) error

type Change

type Change struct {
	Op         string
	ExternalID string
	Before     *catalog.LiveEntity
	After      *catalog.DesiredEntity
	FieldDiffs map[string][2]string
}

type Counts

type Counts struct {
	Create int
	Update int
	Delete int
	Noop   int
}

func (Counts) IsNoop

func (c Counts) IsNoop() bool

type JSONChange

type JSONChange struct {
	Op         string               `json:"op"`
	ExternalID string               `json:"external_id"`
	Name       string               `json:"name"`
	FieldDiffs map[string][2]string `json:"field_diffs,omitempty"`
}

JSONChange is a single change entry in JSON output.

type JSONOutput

type JSONOutput struct {
	Catalog   string       `json:"catalog"`
	CatalogID string       `json:"catalog_id"`
	Counts    Counts       `json:"counts"`
	Changes   []JSONChange `json:"changes"`
}

JSONOutput is the structured output for --output=json mode.

type Plan

type Plan struct {
	Catalog   string
	CatalogID string
	Changes   []Change
	Counts    Counts
}

func Diff

func Diff(catalogName string, catalogID string, live []catalog.LiveEntity, desired []catalog.DesiredEntity, allowPrune bool) *Plan

func LoadPlan

func LoadPlan(path string) (*Plan, error)

type StaleChange

type StaleChange struct {
	ExternalID string
	Reason     string
}

StaleChange describes a single plan change that no longer matches live state.

func ValidatePlanFreshness

func ValidatePlanFreshness(plan *Plan, live []catalog.LiveEntity) []StaleChange

ValidatePlanFreshness checks whether a saved plan still matches live state. It returns a list of stale changes; an empty slice means the plan is fresh.

Jump to

Keyboard shortcuts

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