s3

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package s3 implements the Destination interface for S3 and S3-compatible stores (AWS, MinIO, Wasabi, Backblaze B2, IDrive). It is create-only: there is no delete or overwrite path. Credentials come from the AWS SDK default chain, static keys (S3-compatible) are supplied via AWS_* env, never hand-resolved here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

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

Backend is a create-only S3 Destination.

func New

func New(ctx context.Context, opts Options, logger *slog.Logger) (*Backend, error)

New builds an S3 backend using the default credential chain.

func (*Backend) Get

func (b *Backend) Get(ctx context.Context, key string) (io.ReadCloser, error)

Get opens key for reading (read-only). Caller closes the reader.

func (*Backend) List

func (b *Backend) List(ctx context.Context, prefix string) ([]dest.Object, error)

List returns objects under prefix (read-only).

func (*Backend) ObserveRetention added in v0.1.16

func (b *Backend) ObserveRetention(ctx context.Context, key string) (dest.RetentionObservation, time.Time, error)

ObserveRetention asks S3 what retention is actually on an object gitdr wrote.

`GetObjectRetention` rather than `HeadObject`, and the difference decides whether this check is usable at all. HeadObject returns `x-amz-object-lock-mode` **only if the caller holds `s3:GetObjectRetention`** - without it the response is a 200 with the headers silently omitted, byte-identical to an object that carries no retention. SPEC tells every operator to scope destination credentials create/put-only, so a HEAD-based check would report "the destination accepted a write it did not retain" about correctly configured, genuinely protected buckets belonging to the operators who followed that advice. That is the unearned negative WormVerdict exists to prevent, and it would teach people to ignore the one warning that matters.

`?retention` fails distinguishably instead:

NoSuchObjectLockConfiguration  the store implements the question and this object holds
                               nothing. An earned negative.
AccessDenied / NotImplemented  a refusal, and a refusal is not a no.
anything else                  unclassified, and unclassified is not a no either.

func (*Backend) PutImmutable

func (b *Backend) PutImmutable(ctx context.Context, key string, r io.Reader, size int64, ret dest.Retention) (dest.PutResult, error)

PutImmutable creates key, create-only, never overwriting or deleting. Object Lock retention is applied only when ret carries a retain-until (i.e. the bucket is immutable); on the non-WORM adoption path we write plainly, because sending lock headers to a bucket without Object Lock is a 400. An explicit CRC32 checksum is always sent: AWS and some S3-compatible stores (Backblaze B2) require Content-MD5 or an x-amz-checksum header on Object Lock PutObject requests.

func (*Backend) VerifyWorm

func (b *Backend) VerifyWorm(ctx context.Context) (dest.WormStatus, error)

VerifyWorm probes bucket Object Lock. A missing lock config is reported as not-locked (so the operator can override); other failures are returned as errors.

type Options

type Options struct {
	Bucket       string
	Region       string // defaults to us-east-1 (also fine for MinIO)
	Endpoint     string // empty = AWS; set for MinIO/Wasabi/B2/IDrive
	UsePathStyle bool   // true for MinIO and most S3-compatible stores
}

Options configures the S3 backend. Credentials are intentionally absent: they are resolved by the SDK default chain (env, IRSA/Pod Identity, instance profile, SSO).

Jump to

Keyboard shortcuts

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