reconcile

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package reconcile evaluates every obligation in a baton file.

Index

Constants

This section is empty.

Variables

View Source
var ErrInventory = errors.New("inventory check failed")

ErrInventory marks a component missing from the project inventory.

View Source
var ErrOptions = errors.New("invalid reconcile options")

ErrOptions marks unusable reconcile options.

Functions

func CheckInventory

func CheckInventory(cfg *config.Config, src source.Source, now time.Time) error

CheckInventory reports components missing from the Security Insights repository list. It reads the current file, not a past one.

func ClockStart

func ClockStart(triggered time.Time, needs []string, byID map[string]*Result) time.Time

ClockStart is when a step's grace starts: the latest time one of its prerequisites became done, or the trigger time when none can say. Waived and not-applicable prerequisites count from the trigger.

Types

type Instance

type Instance struct {
	Rollout  string   `json:"rollout"`
	Key      string   `json:"key"`  // "<repo>:release:<tag>:<commit>"
	Home     string   `json:"home"` // repo that gets the parent issue
	Binding  string   `json:"binding"`
	Commit   string   `json:"commit,omitempty"`
	Complete bool     `json:"complete"`
	Results  []Result `json:"obligations"`
}

Instance is one rollout triggered by one event.

type Options

type Options struct {
	Config    *config.Config
	Source    source.Source
	AsOf, Now time.Time
}

Options configure a reconcile run.

func (*Options) Validate

func (o *Options) Validate() error

Validate checks that the options can run.

type Reconciler

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

Reconciler evaluates obligations.

func New

func New(opts *Options) *Reconciler

New returns a Reconciler for opts.

func (*Reconciler) Run

func (r *Reconciler) Run() (Report, error)

Run checks every rollout and invariant as of opts.AsOf.

type Report

type Report struct {
	AsOf       time.Time  `json:"as_of"`
	Rules      string     `json:"rules,omitempty"` // digest of the rules file
	Instances  []Instance `json:"rollouts"`
	Invariants []Result   `json:"invariants"`
}

Report is everything one run found.

func (*Report) All

func (r *Report) All() []Result

All returns every obligation result in the report.

func (*Report) HasErrors

func (r *Report) HasErrors() bool

HasErrors reports whether any obligation couldn't be evaluated.

type Result

type Result struct {
	ID      string   `json:"id"` // "<rollout>/<id>" or invariant id
	Type    string   `json:"type,omitempty"`
	Target  string   `json:"target"`
	Owners  []string `json:"owners,omitempty"`
	Binding string   `json:"binding"`
	Commit  string   `json:"commit,omitempty"` // trigger tag's commit
	Action  string   `json:"action,omitempty"`
	State   State    `json:"state"`
	AgeDays *int     `json:"age_days,omitempty"`
	// DoneSince is when a done step became done, if its probes can tell.
	DoneSince *time.Time `json:"done_since,omitempty"`
	Evidence  string     `json:"evidence"`
}

Result is one evaluated obligation.

func (*Result) Key

func (r *Result) Key() string

Key identifies an obligation instance across runs. A rollout's obligations include the trigger commit, so a moved tag gets new keys.

type State

type State string

State of one obligation.

const (
	Done          State = "done"
	Pending       State = "pending"
	Overdue       State = "overdue"
	Blocked       State = "blocked"
	Waived        State = "waived"
	Unknown       State = "unknown"
	NotApplicable State = "not-applicable"
	Error         State = "error"
)

Obligation states.

Jump to

Keyboard shortcuts

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