sync

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 7 Imported by: 0

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) error

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