s3

package
v0.10.0-rc13 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 21 Imported by: 0

README

S3 Storage Implementation

Please head over to the S3 Storage Implementation documentation for more information.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidConfig is returned if the S3 configuration is invalid.
	ErrInvalidConfig = errors.New("invalid S3 configuration")

	// ErrBucketNotFound is returned if the specified bucket does not exist.
	ErrBucketNotFound = errors.New("bucket not found")

	// ErrS3EndpointMissingScheme is returned if the S3 endpoint does not include a scheme.
	ErrS3EndpointMissingScheme = errors.New("S3 endpoint must include scheme (http:// or https://)")
)

Functions

func Example

func Example()

Example demonstrates how to use the S3 storage implementation with AWS S3.

func ExampleGarage

func ExampleGarage()

ExampleGarage demonstrates how to use the S3 storage with a self-hosted S3-compatible server such as Garage. Configuration is identical for other S3-compatible servers (Ceph, SeaweedFS, etc.) — just adjust the endpoint and credentials.

Types

type Store

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

Store represents an S3 store and implements storage.Store.

func New

func New(ctx context.Context, cfg s3.Config) (*Store, error)

New creates a new S3 store with the given configuration.

func (*Store) DeleteNar

func (s *Store) DeleteNar(ctx context.Context, narURL nar.URL) error

DeleteNar deletes the nar from the store.

func (*Store) DeleteNarInfo

func (s *Store) DeleteNarInfo(ctx context.Context, hash string) error

DeleteNarInfo deletes the narinfo from the store.

func (*Store) DeleteSecretKey

func (s *Store) DeleteSecretKey(ctx context.Context) error

DeleteSecretKey deletes the secret key in the store.

func (*Store) DeleteStagingParts

func (s *Store) DeleteStagingParts(ctx context.Context, hash string) error

DeleteStagingParts removes all staging part-objects for hash.

func (*Store) GetNar

func (s *Store) GetNar(ctx context.Context, narURL nar.URL) (int64, io.ReadCloser, error)

GetNar returns nar from the store. NOTE: The caller must close the returned io.ReadCloser!

func (*Store) GetNarInfo

func (s *Store) GetNarInfo(ctx context.Context, hash string) (*narinfopkg.NarInfo, error)

GetNarInfo returns narinfo from the store.

func (*Store) GetSecretKey

func (s *Store) GetSecretKey(ctx context.Context) (signature.SecretKey, error)

GetSecretKey returns secret key from the store.

func (*Store) GetStagingPart

func (s *Store) GetStagingPart(ctx context.Context, hash string, index int64) (io.ReadCloser, error)

GetStagingPart opens a staging part-object for reading.

func (*Store) HasNar

func (s *Store) HasNar(ctx context.Context, narURL nar.URL) bool

HasNar returns true if the store has the nar. Any error (confirmed absence or an undeterminable stat) collapses to false; use StatNar to distinguish them.

func (*Store) HasNarInfo

func (s *Store) HasNarInfo(ctx context.Context, hash string) bool

HasNarInfo returns true if the store has the narinfo.

func (*Store) HasNarinfoDir added in v0.9.1

func (s *Store) HasNarinfoDir(ctx context.Context) (bool, error)

HasNarinfoDir checks if any objects exist under the given prefix.

func (*Store) PutNar

func (s *Store) PutNar(ctx context.Context, narURL nar.URL, body io.Reader, size int64) (int64, error)

PutNar puts the nar in the store. If size > 0, it's the known size of the nar (for efficient streaming). If size <= 0, the size is unknown (uses manual multipart upload to avoid memory spike).

func (*Store) PutNarInfo

func (s *Store) PutNarInfo(ctx context.Context, hash string, narInfo *narinfopkg.NarInfo) error

PutNarInfo puts the narinfo in the store.

func (*Store) PutSecretKey

func (s *Store) PutSecretKey(ctx context.Context, sk signature.SecretKey) error

PutSecretKey stores the secret key in the store.

func (*Store) PutStagingPart

func (s *Store) PutStagingPart(
	ctx context.Context,
	hash string,
	index int64,
	body io.Reader,
	size int64,
) (int64, error)

PutStagingPart writes one immutable in-flight staging part-object.

func (*Store) StatNar

func (s *Store) StatNar(ctx context.Context, narURL nar.URL) (bool, error)

StatNar reports whether the store has the nar, distinguishing a confirmed absence (false, nil) from an undeterminable result (false, err). See the storage.NarStore interface for the contract.

func (*Store) WalkNarInfos added in v0.8.0

func (s *Store) WalkNarInfos(ctx context.Context, fn func(hash string) error) error

WalkNarInfos walks all narinfos in the store and calls fn for each one.

func (*Store) WalkNars added in v0.9.2

func (s *Store) WalkNars(ctx context.Context, fn func(narURL nar.URL) error) error

WalkNars walks all NAR files in the store and calls fn for each one.

Jump to

Keyboard shortcuts

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