s3

package
v1.34.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithEndpoint

func WithEndpoint(endpoint string) containers.Option[SnapshotStore]

WithEndpoint configures the region for s3

func WithPollOptions

func WithPollOptions(opts ...containers.Option[storagefs.Poller]) containers.Option[SnapshotStore]

WithPollOptions configures the poller options used when periodically updating snapshot state

func WithPrefix

func WithPrefix(prefix string) containers.Option[SnapshotStore]

WithPrefix configures the prefix for s3

func WithRegion

func WithRegion(region string) containers.Option[SnapshotStore]

WithRegion configures the region for s3

Types

type FS

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

FS is only for accessing files in a single bucket. The directory entries are cached. It is specifically intended for use by a source that calls fs.WalkDir and does not fully implement all fs operations

func NewFS

func NewFS(logger *zap.Logger, s3Client S3ClientAPI, bucket string, prefix string) (*FS, error)

New creates a FS for the single bucket

func (*FS) Open

func (f *FS) Open(name string) (fs.File, error)

Open implements fs.FS. For the S3 filesystem, it fetches the object contents from s3.

func (*FS) ReadDir

func (f *FS) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir implements fs.ReadDirFS. This can only be called on the current directory as the s3 filesystem does not support any kind of recursive directory structure

func (*FS) Stat

func (f *FS) Stat(name string) (fs.FileInfo, error)

Stat implements fs.StatFS. For the s3 filesystem, this gets the objects in the s3 bucket and stores them for later use. Stat can only be called on the currect directory as the s3 filesystem only supports walking a single bucket configured at creation time.

type S3ClientAPI

type S3ClientAPI interface {
	ListObjectsV2(context.Context, *s3.ListObjectsV2Input, ...func(*s3.Options)) (*s3.ListObjectsV2Output, error)
	GetObject(context.Context, *s3.GetObjectInput, ...func(*s3.Options)) (*s3.GetObjectOutput, error)
}

type SnapshotStore

type SnapshotStore struct {
	*storagefs.Poller
	// contains filtered or unexported fields
}

SnapshotStore represents an implementation of storage.SnapshotStore This implementation is backed by an S3 bucket

func NewSnapshotStore

func NewSnapshotStore(ctx context.Context, logger *zap.Logger, bucket string, opts ...containers.Option[SnapshotStore]) (*SnapshotStore, error)

NewSnapshotStore constructs a Store

func (*SnapshotStore) String

func (s *SnapshotStore) String() string

String returns an identifier string for the store type.

func (*SnapshotStore) View

func (s *SnapshotStore) View(fn func(storage.ReadOnlyStore) error) error

View accepts a function which takes a *StoreSnapshot. The SnapshotStore will supply a snapshot which is valid for the lifetime of the provided function call.

Jump to

Keyboard shortcuts

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