Help us shape the future of Go! Take the 2026 Go Developer Survey

pin

package
v0.2.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package pin implements the two-phase pin lifecycle: Plan builds a complete Record of what to pin (pure computation + network reads), and Commit writes the Record to disk (workflow files + lockfile).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Commit

func Commit(ctx context.Context, rec *Record, store *lockfile.State, copts *CommitOptions) error

Commit writes a planned Record to disk: rewrites workflow files and updates the lockfile store. All-or-nothing semantics — if any write fails, previously written files are not rolled back (best-effort), but the error is returned immediately.

Types

type CommitOptions

type CommitOptions struct {
	// OnProgress is called at each phase boundary. Nil means no progress.
	OnProgress func(phase string)
	// SkipNewWorkflowEntries forces the Commit phase to skip workflows with no existing lockfile entry.
	SkipNewWorkflowEntries bool
}

CommitOptions configures the Commit pass.

type Entry

type Entry struct {
	Hostname     string
	NWO          string
	Ref          string
	SHA          string
	ObservedSHA  string
	Resolution   Resolution
	Issue        string
	Reason       string
	Suggestion   string
	AutoFixedRef string // original ref before sane-release rewrite
	OnBranch     string
	Tag          string
	Workflows    []string
	RequiredBy   []string
	Direct       bool
	// RenamedFrom lists the lockfile keys this pin had before a
	// same-repository rename, so their recorded `uses:` carry over.
	RenamedFrom []string
	FullScan    bool
}

Entry records the plan decision for one action dependency.

type PlanOptions

type PlanOptions struct {
	Resolver  *resolve.Resolver
	Tagger    *tag.Lister
	Store     *lockfile.State
	Pool      *pinpool.Pool
	RepoOwner string // for same-owner narrowing skip
	RepoName  string
	// NoNarrow disables tag narrowing: mutable version refs (v4, v3.1)
	// are kept as the lock comment instead of being resolved to full
	// patch tags (v4.2.1). Bare-SHA reverse lookup still applies.
	NoNarrow bool

	// AcceptMoved treats ref-moved and unreachable-pin findings as
	// resolvable: affected deps are pruned from the inventory and
	// re-resolved to their current live SHA.
	AcceptMoved bool

	// Relock treats ref-moved findings (a branch or partial-version ref
	// that legitimately advanced) as resolvable, re-pinning them to the
	// current live SHA. Unlike AcceptMoved it leaves unreachable-pin
	// findings untouched so possible tampering stays a hard error.
	Relock bool

	// PartialScan reports that explicit workflow paths, rather than the full
	// workflow directory, define this run's mutation authority.
	PartialScan bool

	// OnProgress is called at each phase boundary with a human-readable
	// label (e.g. "Resolving actions/checkout"). Nil means no progress.
	OnProgress func(phase string)
	// contains filtered or unexported fields
}

PlanOptions configures the Plan pass.

type Record

type Record struct {
	Entries   []Entry
	Workflows []WorkflowPlan
}

Record is the complete output of Plan: everything Commit needs to write all changes atomically.

func Plan

func Plan(ctx context.Context, report *checks.Report, opts PlanOptions) (*Record, error)

Plan walks an actionmanager Report and produces a Record describing every pin action to take. It does network reads (resolve, reverse lookup, reachability) but no disk writes.

func (*Record) Investigated

func (r *Record) Investigated() []Entry

Investigated returns entries with Resolution == Investigate.

func (*Record) Narrowed added in v0.1.0

func (r *Record) Narrowed() []Entry

Narrowed returns verified entries whose refs were upgraded (AutoFixedRef set).

func (*Record) Pinned

func (r *Record) Pinned() []Entry

Pinned returns entries with Resolution == Pinned.

func (*Record) Unresolved

func (r *Record) Unresolved() []Entry

Unresolved returns entries with Resolution == Unresolved.

func (*Record) Valid

func (r *Record) Valid() bool

Valid reports whether the record contains no investigate or unresolved entries.

type Resolution

type Resolution string

Resolution describes the outcome for a single action reference.

const (
	Pinned      Resolution = "pinned"
	Verified    Resolution = "verified"
	Investigate Resolution = "needs-investigation"
	Skipped     Resolution = "skipped"
	Unresolved  Resolution = "unresolved"
)

Resolution values reported for an action reference.

func (Resolution) String

func (r Resolution) String() string

String returns the resolution as a string.

type WorkflowPlan

type WorkflowPlan struct {
	Path     string
	Rewrites map[string]string
	// RequiredRewrites move redirected `uses:` to the canonical repository;
	// Commit fails rather than skip one.
	RequiredRewrites map[string]string
	// RewrittenIn lists, per RequiredRewrites key, the files Commit found it in.
	RewrittenIn map[string][]string
	// SelfActionFiles are in-repo action definition files reached from this
	// workflow through `$/…`. The same rewrites apply to their `uses:` lines.
	SelfActionFiles []string
}

WorkflowPlan records what Commit must write for one workflow file.

Jump to

Keyboard shortcuts

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