local

package
v1.235.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 27 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package local implements the local directory (local/dir) and local archive (local/archive) artifact repositories behind artifact.Repository. They share one record layout (package layout), one publication lifecycle, one lock implementation, and one detached-evidence store; they differ only in how a payload is stored.

Directory repositories

A local/dir payload is a tree of ordinary copied files below its resolved location, with the distribution documents and manifest.json adjacent at <location>/.atmos/artifact/. Managed readers omit that distribution directory when they materialize user content.

Archive repositories

A local/archive payload is one tar, tgz, or zip file. The repository stores adjacent <payload>.metadata.json and <payload>.docs/README.md|CHANGELOG.md sidecars, so metadata and documents are readable without opening the archive, while the archive itself embeds portable copies for transport. The configured quoted-octal permissions (default 0600) apply to the archive file and its sidecars only; they are distinct from member modes inside the archive. An explicit request the host cannot enforce fails with an unsupported-capability error instead of silently weakening the mode.

Publication and recovery

A publication follows the contracts sequence: reserve the resolved location and record a pending operation journal, mark the reference pending, stage the payload on the same filesystem, write the immutable Record, install the payload and sidecars, write the representation, and only then flip the reference to completed. Pending references are unavailable to readers and invisible to listing. Readers recheck the reference generation after reading from the mutable payload location, so replaced bytes are never served under an old digest.

An interrupted or failed force replacement leaves the reference unavailable until a retry with the same intent repairs it; there is no rollback. A pending operation of a different intent is never stolen: publication fails with a recovery diagnostic naming the operation ID.

Locks

Lock returns an OS-backed file lock (host scope only) with an ownership token. It is held for the reference and, during publication, for the resolved location. The OS releases the lock when its owner exits. Acquisition is cancel-safe: a canceled wait leaks no ownership.

Signatures

Signature evidence is stored as detached files below the reserved namespace and is bound to the canonical Record digest. Adding evidence never changes the Record, the reference, or the archive: evidence added after publication does not claim that the original archive bytes were signed, only the Record that describes them. Cryptographic verification is delegated to an injected artifact.Verifier; without one, the repository advertises no evidence formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Descriptor

func Descriptor(kind string, opts ...Option) artifact.KindDescriptor

Descriptor returns the static descriptor of a local kind: the built-in descriptor refined with the capabilities the registered backend actually provides (deletion, enumeration, conditional updates, detached evidence for the verifier's formats). It needs no I/O.

func Kinds

func Kinds() []string

Kinds lists the repository kinds this package registers.

func Register

func Register(opts ...Option) error

Register registers the local/dir and local/archive repository kinds in the process-wide registry. It is called explicitly by a composition root, never from init. Options such as WithVerifier apply to every repository the registered factories construct. It does not touch the legacy CI artifact registry, whose own "local/dir" store is a different thing.

func RegisterWith

func RegisterWith(registry *artifact.RepositoryRegistry, opts ...Option) error

RegisterWith registers the local kinds in the given registry. A kind that is already registered is an error, so double registration is caught instead of silently replaced.

Types

type Option

type Option func(*settings)

Option configures a local repository or its registration.

func WithOwner

func WithOwner(owner string) Option

WithOwner sets the owner recorded in lock requests and operation journals when the caller does not supply one. The default is "<hostname>:<pid>".

func WithVerifier

func WithVerifier(verifier artifact.Verifier) Option

WithVerifier injects the cryptographic verifier used by Verify. The formats it understands are the evidence formats the repository advertises. Without a verifier the repository stores no evidence and Sign and Verify return unsupported-capability errors.

type Repository

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

Repository is a local directory or local archive artifact repository. Construct it with NewDir or NewArchive. It is safe for concurrent use: all coordination happens through OS file locks and atomic file replacement on disk.

func NewArchive

func NewArchive(alias string, cfg *schema.ArtifactRepositoryConfig, opts ...Option) (*Repository, error)

NewArchive returns a local/archive repository for the configuration. It performs no I/O.

func NewDir

func NewDir(alias string, cfg *schema.ArtifactRepositoryConfig, opts ...Option) (*Repository, error)

NewDir returns a local/dir repository for the configuration. It performs no I/O: the root is created by the first write.

func (*Repository) Capabilities

func (r *Repository) Capabilities() artifact.Capabilities

Capabilities implements artifact.Repository. It is computed from configuration alone.

func (*Repository) Delete

Delete implements artifact.Repository. Deletion is scoped to the selected artifact: its reference, its Record, its representation, its detached evidence, and the payload and sidecars it exclusively owns. Nothing outside the repository root is touched, and files the repository does not manage (a user's extra file inside a payload directory) stay in place.

The reference record is removed first, so the artifact disappears atomically; an interruption afterwards leaves garbage that a later publication of the same reference clears, never a reference that points at missing bytes. A pending publication is never deleted: its owner must repair it with the same intent.

func (*Repository) Inspect

Inspect implements artifact.Repository. It reads only managed records and the small adjacent metadata copy; it never opens the payload.

func (*Repository) List

List implements artifact.Repository. It enumerates managed completed references only: never arbitrary user files, pending publications, staging, or journals. Entries are sorted by name then version.

func (*Repository) Lock

Lock implements artifact.LockProvider with an OS-backed file lock of host scope. It waits for a competing owner until ctx ends; a canceled wait leaks no ownership. Leases are rejected because a paused writer could not be fenced, and repository scope is rejected because a local file lock cannot exclude writers on other hosts.

func (*Repository) LockNamespace

func (r *Repository) LockNamespace() string

LockNamespace implements artifact.LockNamespacer: the repository root identifies the collection.

func (*Repository) OpenDocument

OpenDocument implements artifact.Repository without reading the payload. The reader verifies the document digest and size and rechecks the reference generation at EOF.

func (*Repository) Pin

Pin implements artifact.Repository. It resolves the reference and lists the evidence descriptors known now. It takes no lock and grants no trust.

func (*Repository) Publish

func (r *Repository) Publish(ctx context.Context, prepared *artifact.PreparedArtifact, options artifact.PublishOptions) (result *artifact.PublishResult, err error)

Publish implements artifact.Repository with the publication sequence of the contracts:

  1. Hold the reference lock (the service's, or one taken here) and the resolved-location lock.
  2. Read the current reference and admit the publication: conflict, force, unchanged, or resume.
  3. Reserve the location and record the pending operation journal and pending reference before any payload path changes.
  4. Stage the payload and sidecars on the same filesystem, write the immutable Record, install the payload, and write the representation.
  5. Complete the reference last, with an atomic replacement.
  6. Clean up only the temporary resources this operation owns.

A failure after step 3 leaves the reference pending: unavailable to readers, repaired by a retry with the same intent. The caller reconciles an ambiguous response by reading the reference.

func (*Repository) Read

Read implements artifact.Repository. It opens the verified streams of exactly the pinned Record. The reference must still name that Record; after the caller reads the streams, the reference generation is rechecked, so bytes that changed underneath the reader are reported instead of served under the old digest.

func (*Repository) ReadEvidence

func (r *Repository) ReadEvidence(ctx context.Context, pinned *artifact.PinnedReference) ([]artifact.EvidenceBlob, error)

ReadEvidence implements artifact.EvidenceReader: it exports the stored evidence blobs of a pinned artifact so a copy through the shared staging path can carry them along. The evidence is untrusted until verified.

func (*Repository) Resolve

Resolve implements artifact.Repository. A version reference resolves once to the digest of its immutable Record, which every later operation uses. A pending reference is unavailable; a digest reference checks the Record's embedded name and names only the current Record.

func (*Repository) Root

func (r *Repository) Root() string

Root returns the absolute repository root.

func (*Repository) Sign

Sign implements artifact.Repository: it asks the signer for evidence over the Record subject and stores it as a detached file named by the evidence digest. Evidence lives beside the Record, so signing never changes the Record, the reference, or the payload. A signature added after publication covers the Record that describes the archive, not the original archive bytes.

func (*Repository) Verify

Verify implements artifact.Repository. It authenticates the stored evidence with the injected verifier; it never trusts a cached verdict. No evidence, an unverifiable format, or an unsatisfied policy is a failure.

func (*Repository) WriteEvidence

func (r *Repository) WriteEvidence(ctx context.Context, pinned *artifact.PinnedReference, evidence []artifact.EvidenceBlob, lock artifact.LockHandle) (stored []artifact.SignatureEvidence, err error)

WriteEvidence implements artifact.EvidenceWriter: it imports evidence for an artifact this repository already holds. The evidence must bind to the pinned Record and carry matching bytes; importing never changes the Record or the reference.

Jump to

Keyboard shortcuts

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