r2

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0, MIT Imports: 16 Imported by: 0

Documentation

Overview

Package r2 stores package repository objects in Cloudflare R2 through its S3 API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Credentials

type Credentials struct {
	// AccessKeyID is the R2 API token access key.
	AccessKeyID rel.Secret
	// SecretAccessKey is the R2 API token secret.
	SecretAccessKey rel.Secret
	// SessionToken is optional for S3-compatible integration tests.
	SessionToken rel.Secret
}

Credentials contains the static S3 authentication values used by R2.

type Options

type Options struct {
	// AccountID is the Cloudflare account that owns the bucket.
	// It is required when Endpoint is empty.
	AccountID string
	// Endpoint overrides the account-derived S3 endpoint.
	// It exists for S3-compatible integration tests.
	Endpoint string
	// Bucket is the existing R2 bucket name.
	Bucket string
	// Credentials are the least-privilege S3 API credentials.
	Credentials Credentials
}

Options configures a Store.

type Store

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

Store streams package repository objects through the AWS S3 client.

func New

func New(ctx context.Context, options Options) (*Store, error)

New constructs an R2 store using static S3 credentials and path-style requests.

func (*Store) Download

func (s *Store) Download(
	ctx context.Context,
	objectPath string,
	destination io.Writer,
) (pkgrepo.StoredContent, error)

Download implements pkgrepo.Store.

func (*Store) List

func (s *Store) List(ctx context.Context) ([]pkgrepo.StoredObject, error)

List implements pkgrepo.Store.

func (*Store) Stat

func (s *Store) Stat(ctx context.Context, objectPath string) (pkgrepo.StoredContent, bool, error)

Stat implements pkgrepo.Store.

func (*Store) Upload

func (s *Store) Upload(ctx context.Context, request pkgrepo.UploadRequest) error

Upload implements pkgrepo.Store.

Directories

Path Synopsis
Package mocks provides generated object-store test doubles.
Package mocks provides generated object-store test doubles.

Jump to

Keyboard shortcuts

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