archive

package
v0.33.13 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package archive uploads task HTML to cold object storage (R2, S3, B2) and exposes the canonical key layout used by the HTML persister.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColdKey

func ColdKey(jobID, taskID string) string

func LighthouseObjectPath added in v0.33.10

func LighthouseObjectPath(jobID, taskID, profile string, runID int64) string

Empty taskID (parent deleted via ON DELETE SET NULL on lighthouse_runs.source_task_id) falls back to a run-id keyed path so the audit is still archived.

func TaskHTMLObjectPath

func TaskHTMLObjectPath(jobID, taskID string) string

ARCHIVE_PATH_PREFIX (when set) is prepended with a "/" join so review-app deployments stay siloed from the production bucket layout.

Types

type ColdStorageProvider

type ColdStorageProvider interface {
	// Call at startup to catch bad credentials/endpoints early.
	Ping(ctx context.Context, bucket string) error
	Upload(ctx context.Context, bucket, key string, data io.Reader, opts UploadOptions) error
	Download(ctx context.Context, bucket, key string) (io.ReadCloser, error)
	Exists(ctx context.Context, bucket, key string) (bool, error)
	// Returns one of: "r2", "s3", "b2".
	Provider() string
}

ColdStorageProvider abstracts an S3-compatible object store.

func ProviderFromEnv

func ProviderFromEnv() (ColdStorageProvider, error)

ProviderFromEnv builds a ColdStorageProvider from ARCHIVE_* env vars. Returns (nil, nil) if ARCHIVE_PROVIDER is unset.

type Config

type Config struct {
	Provider string // "r2", "s3", "b2"
	Bucket   string
}

func ConfigFromEnv

func ConfigFromEnv() *Config

Returns nil when ARCHIVE_PROVIDER or ARCHIVE_BUCKET is unset (feature disabled).

func DefaultConfig

func DefaultConfig() Config

type S3Provider

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

S3Provider implements ColdStorageProvider for any S3-compatible service (Cloudflare R2, Backblaze B2, AWS S3, MinIO, etc.).

func NewS3Provider

func NewS3Provider(endpoint, accessKeyID, secretAccessKey, region, providerName string) (*S3Provider, error)

NewS3Provider creates a provider from explicit credentials.

func (*S3Provider) Delete

func (p *S3Provider) Delete(ctx context.Context, bucket, key string) error

func (*S3Provider) Download

func (p *S3Provider) Download(ctx context.Context, bucket, key string) (io.ReadCloser, error)

func (*S3Provider) Exists

func (p *S3Provider) Exists(ctx context.Context, bucket, key string) (bool, error)

func (*S3Provider) Ping

func (p *S3Provider) Ping(ctx context.Context, bucket string) error

func (*S3Provider) Provider

func (p *S3Provider) Provider() string

func (*S3Provider) Upload

func (p *S3Provider) Upload(ctx context.Context, bucket, key string, data io.Reader, opts UploadOptions) error

type UploadOptions

type UploadOptions struct {
	ContentType     string
	ContentEncoding string
	Metadata        map[string]string
}

Jump to

Keyboard shortcuts

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