lockfile

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package lockfile owns skeeper.lock encoding, validation, and digesting.

Index

Constants

View Source
const (
	// Filename is the committed root lockfile path.
	Filename = "skeeper.lock"
	// Version is the current lockfile schema version.
	Version = 1
)

Variables

This section is empty.

Functions

func CanonicalSidecarURL

func CanonicalSidecarURL(value string) string

CanonicalSidecarURL canonicalizes sidecar URLs for lock comparison.

func Marshal

func Marshal(lock Lock) ([]byte, error)

Marshal returns canonical JSON bytes for lock.

func Validate

func Validate(lock Lock) error

Validate checks lock schema invariants.

Types

type DigestResult

type DigestResult struct {
	Digest NamespaceDigest
	Files  int
	Bytes  int64
}

DigestResult describes a namespace digest and its scale.

func DigestWorkingTree

func DigestWorkingTree(root string, files []string, staged map[string]string) (DigestResult, error)

DigestWorkingTree calculates a digest from main-repo file contents.

type JSONStore

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

JSONStore is the production lockfile store.

func NewStore

func NewStore(runner gitexec.Runner) *JSONStore

NewStore returns a JSON lockfile store.

func (*JSONStore) Digest

func (s *JSONStore) Digest(
	ctx context.Context,
	sidecarDir string,
	namespace config.Namespace,
	ref reconcile.SidecarRef,
) (NamespaceDigest, error)

Digest calculates a namespace tree digest at ref.

func (*JSONStore) DigestResult

func (s *JSONStore) DigestResult(
	ctx context.Context,
	sidecarDir string,
	namespace config.Namespace,
	ref reconcile.SidecarRef,
) (DigestResult, error)

DigestResult calculates a namespace tree digest and scale at ref.

func (*JSONStore) Load

func (s *JSONStore) Load(root reconcile.RepoRoot) (Lock, error)

Load reads and validates skeeper.lock.

func (*JSONStore) RegenerateForMerge

func (s *JSONStore) RegenerateForMerge(_ context.Context, root reconcile.RepoRoot) (Lock, error)

RegenerateForMerge reloads the canonical lock after the merge driver updated it.

func (*JSONStore) Write

func (s *JSONStore) Write(root reconcile.RepoRoot, lock Lock) error

Write writes lock with canonical JSON encoding.

type Lock

type Lock struct {
	Version      int               `json:"version"`
	Sidecar      string            `json:"sidecar"`
	SourceBranch string            `json:"source_branch"`
	Namespaces   []NamespaceRecord `json:"namespaces"`
}

Lock is the canonical JSON lockfile committed to the main repository.

func Normalize

func Normalize(lock Lock) Lock

Normalize canonicalizes lock field order and URL representation.

type NamespaceDigest

type NamespaceDigest string

NamespaceDigest is a deterministic digest for one namespace tree.

type NamespaceRecord

type NamespaceRecord struct {
	Name          string          `json:"name"`
	SidecarBranch string          `json:"sidecar_branch"`
	Commit        string          `json:"commit"`
	Digest        NamespaceDigest `json:"digest"`
	Files         int             `json:"files"`
	Bytes         int64           `json:"bytes"`
}

NamespaceRecord points one namespace to the sidecar commit it expects.

type Store

type Store interface {
	Load(root reconcile.RepoRoot) (Lock, error)
	Write(root reconcile.RepoRoot, lock Lock) error
	Digest(
		ctx context.Context,
		sidecarDir string,
		namespace config.Namespace,
		ref reconcile.SidecarRef,
	) (NamespaceDigest, error)
	RegenerateForMerge(ctx context.Context, root reconcile.RepoRoot) (Lock, error)
}

Store owns lockfile persistence and sidecar digests.

Jump to

Keyboard shortcuts

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