Documentation
¶
Overview ¶
Package s3 implements the aws/s3 artifact repository behind artifact.Repository. It stores the same record layout as the local repositories (package layout) and follows the same publication lifecycle, over a transport-only blob.Store. Production repositories build the AWS SDK store lazily from configuration; tests inject any store, typically the in-process fake S3 server.
Object layout ¶
Below the configured bucket and prefix the managed records live in the reserved ".atmos-artifacts/v1/" namespace: reference, Record, representation, operation journal, detached evidence, and lock-claim objects. The payload lives outside it at the location rendered once, at publication, from the key_pattern.
- packaging none stores one object per file below <location>/, with the distribution documents and manifest.json adjacent at <location>/.atmos/artifact/. Directories, symlinks, and modes are not S3 concepts: the Record inventory carries them and materialization restores them.
- packaging tar, tgz, or zip stores one archive object at <location> with adjacent <location>.metadata.json and <location>.docs/README.md|CHANGELOG.md objects.
The configured S3 object tags are written on every object a publication creates (payload, documents, records, journals, claims, evidence). Portable labels stay in the Record and are never copied into tags.
Publication and conditional writes ¶
A publication reserves its location and records a pending operation journal, marks the reference pending, uploads the payload and documents, writes the immutable Record and the representation, and only then flips the reference to completed. Reference ownership is a conditional write: If-None-Match for a first publication and If-Match with the observed ETag for every later state change, so a concurrent writer loses with a conflict instead of overwriting. ETags are concurrency tokens only; every consumed byte is verified against the digest in the Record. A response that was lost after the request was sent is reconciled by reading the reference back, never assumed to have failed. An endpoint that cannot enforce a required condition fails the operation with an unsupported-capability error and never overwrites. Streaming uploads use bounded multipart transfers and abort the upload on cancellation.
An interrupted or failed force replacement leaves the reference pending, and so unavailable to readers, until a retry with the same intent repairs it; there is no rollback. A pending operation of a different intent is never stolen.
A completed publication keeps its journal until the cleanup that follows completion has removed everything the journal lists: the replaced Record with its payload and evidence, and the payloads of abandoned attempts. Until then those locations stay claimed, so no other reference can reserve one, and each removal is by exact journaled key and safe to repeat. A republication with the same intent finishes the cleanup; a forced replacement or a deletion finishes it before it writes anything, and stops with the journal intact when it cannot.
A reference owns the exact keys its payloads consist of, not the location as a prefix. Before it writes anything, a publication refuses a key below an owned location that already holds an object the reference does not own, so an object a user added there is never overwritten.
Locks and recovery ¶
Lock provides repository-scope mutation coordination through owner claim objects under the managed namespace. A claim is created with If-None-Match, carries an ownership token, and is released with a token check and a conditional delete. V1 claims never expire and are never stolen: a paused or crashed writer cannot become an unfenced stale owner. S3 Object Lock retention is unrelated and is not used.
A writer that crashes while holding a claim leaves it behind. Every later attempt then fails with a recovery diagnostic that names the claim object, its resource, the owner, and the operation. The operator confirms the owning writer has stopped and deletes that one claim object (for example with the AWS console or "aws s3 rm"); nothing else needs to change. The brief repository-wide claim taken while a location is reserved is recovered the same way.
An acquisition whose create outcome is uncertain stops without a lock, and nothing protected by that lock is mutated. The error names the claim object and the attempt's owner, operation, and lock ID. An empty read or an elapsed timeout never proves the uncertain create cannot still commit, so the attempt may leave behind either its own claim (with that lock ID) or a reconciliation fence whose owner starts with "pending reconciliation". Neither expires or is removed automatically, and another owner's claim is never deleted. To recover, the operator confirms the writer that reported the error has exited, checks that the claim object still names that attempt, and deletes that one object deliberately. Later attempts report the claim as held until then.
Signatures ¶
Evidence is stored as digest-named objects below the signature directory of the canonical Record digest. Adding evidence never changes the Record, the reference, or the payload. Cryptographic verification is delegated to an injected artifact.Verifier; without one the repository advertises no evidence formats.
Identity ¶
A configured identity is resolved lazily on first use, through the injected resolver, and an identity that cannot be resolved fails closed: there is no fallback to ambient credentials. Construction, capability description, and dry runs perform no network access.
Index ¶
- Constants
- func Descriptor(opts ...Option) artifact.KindDescriptor
- func Kinds() []string
- func Register(opts ...Option) error
- func RegisterWith(registry *artifact.RepositoryRegistry, opts ...Option) error
- type Option
- type Repository
- func (r *Repository) Capabilities() artifact.Capabilities
- func (r *Repository) Delete(ctx context.Context, pinned artifact.PinnedReference, ...) (result *artifact.DeleteResult, err error)
- func (r *Repository) Inspect(ctx context.Context, pinned artifact.PinnedReference) (*artifact.Inspection, error)
- func (r *Repository) List(ctx context.Context, query artifact.ListQuery) (*artifact.ListPage, error)
- func (r *Repository) Location() string
- func (r *Repository) Lock(ctx context.Context, request artifact.LockRequest) (artifact.LockHandle, error)
- func (r *Repository) LockNamespace() string
- func (r *Repository) OpenDocument(ctx context.Context, pinned artifact.PinnedReference, ...) (*artifact.DocumentStream, error)
- func (r *Repository) Pin(ctx context.Context, ref artifact.Ref) (artifact.PinnedReference, error)
- func (r *Repository) Publish(ctx context.Context, prepared *artifact.PreparedArtifact, ...) (result *artifact.PublishResult, err error)
- func (r *Repository) Read(ctx context.Context, pinned artifact.PinnedReference) (*artifact.Content, error)
- func (r *Repository) ReadEvidence(ctx context.Context, pinned *artifact.PinnedReference) ([]artifact.EvidenceBlob, error)
- func (r *Repository) Resolve(ctx context.Context, ref artifact.Ref) (artifact.PinnedReference, error)
- func (r *Repository) Sign(ctx context.Context, subject artifact.SignatureSubject, signer artifact.Signer, ...) (result []artifact.SignatureEvidence, err error)
- func (r *Repository) Verify(ctx context.Context, subject artifact.SignatureSubject, ...) (*artifact.VerificationResult, error)
- func (r *Repository) WriteEvidence(ctx context.Context, pinned *artifact.PinnedReference, ...) (stored []artifact.SignatureEvidence, err error)
Constants ¶
const ( // DefaultConcurrency bounds the objects and multipart parts uploaded at once. DefaultConcurrency = blobs3.DefaultConcurrency // DefaultLockWait is how long Lock waits for a competing owner before it reports the claim. DefaultLockWait = 30 * time.Second )
Defaults of the repository.
Variables ¶
This section is empty.
Functions ¶
func Descriptor ¶
func Descriptor(opts ...Option) artifact.KindDescriptor
Descriptor returns the static descriptor of the aws/s3 kind: the built-in descriptor refined with the capabilities the registered backend provides. It needs no I/O.
func Register ¶
Register registers the aws/s3 repository kind 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 factory constructs. It does not touch the legacy CI artifact registry, whose own "aws/s3" store is a different thing.
func RegisterWith ¶
func RegisterWith(registry *artifact.RepositoryRegistry, opts ...Option) error
RegisterWith registers the aws/s3 kind 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 an S3 repository or its registration.
func WithConcurrency ¶
WithConcurrency bounds the objects uploaded at once and, for a store built from configuration, the multipart parts per object. The default is DefaultConcurrency.
func WithLockWait ¶
WithLockWait bounds how long Lock waits for a competing owner. Past it, Lock fails with a conflict that names the claim object. Claims never expire, so waiting longer only helps when the owner is alive.
func WithOwner ¶
WithOwner sets the owner recorded in lock claims and operation journals when the caller does not supply one. The default is "<hostname>:<pid>".
func WithPartSize ¶
WithPartSize sets the multipart part size of a store built from configuration. Real S3 requires at least 5 MiB for every part but the last; smaller sizes are for emulators.
func WithStore ¶
WithStore injects the object store. Without it the repository builds the AWS SDK store from its configuration. The injected store must be rooted at the configured prefix, because the repository hands it keys relative to that root. It does not need to apply the configured tags: the repository passes them on every write.
func WithVerifier ¶
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 an aws/s3 artifact repository. Construct it with New. It is safe for concurrent use: all coordination happens through conditional writes and claim objects in the bucket.
func New ¶
func New(alias string, cfg *schema.ArtifactRepositoryConfig, opts ...Option) (*Repository, error)
New returns an aws/s3 repository for the configuration. It performs no network access and resolves no credentials: the AWS client, and the configured identity, are built on first use.
func (*Repository) Capabilities ¶
func (r *Repository) Capabilities() artifact.Capabilities
Capabilities implements artifact.Repository. It is computed from configuration alone.
func (*Repository) Delete ¶
func (r *Repository) Delete(ctx context.Context, pinned artifact.PinnedReference, options artifact.DeleteOptions) (result *artifact.DeleteResult, err error)
Delete implements artifact.Repository. Deletion is scoped to the selected artifact: its reference, its Record, its representation, its detached evidence, and the payload objects it exclusively owns. Objects the repository does not manage (a user's extra object below a payload prefix) stay in place, and nothing outside the repository prefix is touched.
The reference is first made unavailable using the existing pending state; its journal retains payload ownership until cleanup succeeds. A later publication can finish interrupted deletion. A pending publication is never deleted: its owner must repair it with the same intent.
func (*Repository) Inspect ¶
func (r *Repository) Inspect(ctx context.Context, pinned artifact.PinnedReference) (*artifact.Inspection, error)
Inspect implements artifact.Repository. It reads only managed records; it never opens the payload or its documents.
func (*Repository) List ¶
func (r *Repository) List(ctx context.Context, query artifact.ListQuery) (*artifact.ListPage, error)
List implements artifact.Repository. It enumerates managed completed references only: never arbitrary user objects, pending publications, journals, or claims. The reference objects are listed with the store's pagination, so any number of references is found; entries are returned sorted by name then version, which the hashed reference keys cannot provide on their own.
func (*Repository) Location ¶
func (r *Repository) Location() string
Location returns the display locator of the repository: s3://bucket[/prefix].
func (*Repository) Lock ¶
func (r *Repository) Lock(ctx context.Context, request artifact.LockRequest) (artifact.LockHandle, error)
Lock implements artifact.LockProvider with repository-scope owner claims. A claim object is created with If-None-Match; a competing owner waits until ctx ends or the configured wait elapses and then receives a conflict that names the claim. Claims never expire and are never taken over, so leases are rejected, and an endpoint that cannot enforce If-None-Match offers no lock at all. A canceled acquisition leaks no ownership.
func (*Repository) LockNamespace ¶
func (r *Repository) LockNamespace() string
LockNamespace implements artifact.LockNamespacer: the bucket and prefix identify the collection.
func (*Repository) OpenDocument ¶
func (r *Repository) OpenDocument(ctx context.Context, pinned artifact.PinnedReference, role artifact.DocumentRole) (*artifact.DocumentStream, error)
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 ¶
func (r *Repository) Pin(ctx context.Context, ref artifact.Ref) (artifact.PinnedReference, error)
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:
- Hold the reference lock (the service's, or one taken here).
- Read the current reference and admit the publication: conflict, force, unchanged, or resume.
- Reserve the location and record the pending operation journal and pending reference before any payload object is written. Reference ownership is a conditional write.
- Upload the payload and documents, verifying every byte, then write the immutable Record and the representation.
- Complete the reference last, with a conditional write on the pending state's ETag.
- Clean up only the objects this operation owns.
A failure after step 3 leaves the reference pending: unavailable to readers, repaired by a retry with the same intent. A response lost after the request was sent is reconciled by reading the reference back.
func (*Repository) Read ¶
func (r *Repository) Read(ctx context.Context, pinned artifact.PinnedReference) (*artifact.Content, error)
Read implements artifact.Repository. It opens the verified streams of exactly the pinned Record. The reference must still name that Record; the streams open their objects lazily, and when the caller reads one to its end the reference generation is rechecked, so bytes that changed underneath the reader are reported instead of served under the old digest. ETags play no part: every stream is verified against the digest in the Record.
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 ¶
func (r *Repository) Resolve(ctx context.Context, ref artifact.Ref) (artifact.PinnedReference, error)
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) Sign ¶
func (r *Repository) Sign(ctx context.Context, subject artifact.SignatureSubject, signer artifact.Signer, options artifact.SignOptions) (result []artifact.SignatureEvidence, err error)
Sign implements artifact.Repository: it asks the signer for evidence over the Record subject and stores it as an object named by the evidence digest below the subject's directory. Evidence lives beside the Record, so signing never changes the Record, the reference, or the payload.
func (*Repository) Verify ¶
func (r *Repository) Verify(ctx context.Context, subject artifact.SignatureSubject, policy artifact.VerificationPolicy) (*artifact.VerificationResult, error)
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.