checkpointpolicy

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const CheckpointVersionBranchV1 = "branch-v1"

CheckpointVersionBranchV1 identifies the branch-backed checkpoint format.

View Source
const PolicyFileName = "policy.json"
View Source
const RefName = plumbing.ReferenceName("refs/entire/policies/checkpoint")

Variables

This section is empty.

Functions

func CanRead

func CanRead(format CheckpointFormat) bool

func CanSatisfyPolicy added in v0.8.0

func CanSatisfyPolicy(policy Policy) bool

func CanWrite

func CanWrite(format CheckpointFormat) bool

func Compare

func Compare(a, b CheckpointFormat) int

func DefaultCheckpointVersion added in v0.8.0

func DefaultCheckpointVersion() string

func Push

func Push(ctx context.Context, target Target) error

func RequiresUpgrade

func RequiresUpgrade(policy Policy) bool

func SetRef

func SetRef(repo *git.Repository, ref plumbing.ReferenceName, hash plumbing.Hash) error

func UnsupportedPolicyMessage added in v0.8.0

func UnsupportedPolicyMessage(policy Policy, updateCommand string) string

func UnsupportedWrite

func UnsupportedWrite(policy Policy) bool

func ValidatePolicy

func ValidatePolicy(policy Policy) error

func WriteLocal

func WriteLocal(ctx context.Context, repo *git.Repository, parent plumbing.Hash, policy Policy) (plumbing.Hash, error)

Types

type CheckpointFamily

type CheckpointFamily string
const (
	CheckpointFamilyBranch CheckpointFamily = "branch"
	CheckpointFamilyRefs   CheckpointFamily = "refs"
)

type CheckpointFormat

type CheckpointFormat struct {
	Family CheckpointFamily
	Major  int
}

func ParseFormat

func ParseFormat(raw string) (CheckpointFormat, error)

func (CheckpointFormat) String

func (f CheckpointFormat) String() string

type Policy

type Policy struct {
	CheckpointVersion    string `json:"checkpoint_version,omitempty"`
	CheckpointMinVersion string `json:"checkpoint_min_version,omitempty"`
}

func DefaultPolicy

func DefaultPolicy() Policy

func Normalize

func Normalize(policy Policy) Policy

type RemoteState

type RemoteState struct {
	Exists bool
	Hash   plumbing.Hash
}

func CheckRemote

func CheckRemote(ctx context.Context, target Target) (RemoteState, error)

type Source

type Source string
const (
	SourceDefaults      Source = "defaults"
	SourceLocal         Source = "local"
	SourceRemote        Source = "remote"
	SourceLocalDiverged Source = "local-diverged"
)

type State

type State struct {
	Policy     Policy
	Source     Source
	Hash       plumbing.Hash
	RemoteHash plumbing.Hash
}

func ReadFromRef

func ReadFromRef(ctx context.Context, repo *git.Repository, refName plumbing.ReferenceName, source Source) (State, error)

func ReadLocal

func ReadLocal(ctx context.Context, repo *git.Repository) (State, error)

func Sync

func Sync(ctx context.Context, repo *git.Repository, target Target) (State, error)

func SyncFrom added in v0.10.1

func SyncFrom(ctx context.Context, repo *git.Repository, targets []Target) (State, error)

SyncFrom reconciles the local checkpoint policy ref against the first target that has a policy ref. Targets are tried in order; a target lacking the policy ref and a target failing at the transport level both advance to the next target (failures logged at debug); when no target yields a baseline and at least one failed, the FIRST failure is surfaced. A winning target marked SkipLocalUpdate contributes a read-only baseline: it is compared and reported but never advances the local policy ref.

func Update

func Update(ctx context.Context, repo *git.Repository, target Target, opts UpdateOptions) (State, error)

type Target

type Target struct {
	Remote string
	Dir    string

	// SkipLocalUpdate marks a read-only (legacy-tier) candidate: a policy
	// baseline found on it may be read, compared, and reported, but never
	// advances the local policy ref via SetRef. Push targets and the elected
	// checkpoint sync remote leave this false. The zero value preserves the
	// historical single-target Sync behavior (pre-push hook path).
	SkipLocalUpdate bool
}

func ResolveTarget

func ResolveTarget(ctx context.Context) (Target, error)

type UpdateOptions

type UpdateOptions struct {
	CheckpointVersion       string
	CheckpointVersionSet    bool
	CheckpointMinVersion    string
	CheckpointMinVersionSet bool
	Force                   bool
}

Jump to

Keyboard shortcuts

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