s3utils

package
v0.0.0-...-963cbb1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package s3utils implements utilities used to interact with S3.

Package s3utils implements utilities used to interact with S3.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	CopyObject(ctx context.Context, params *s3.CopyObjectInput, optFns ...func(*s3.Options)) (*s3.CopyObjectOutput, error)
	DeleteObject(ctx context.Context, params *s3.DeleteObjectInput, optFns ...func(*s3.Options)) (*s3.DeleteObjectOutput, error)
	GetObject(ctx context.Context, params *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)
	HeadObject(ctx context.Context, params *s3.HeadObjectInput, optFns ...func(*s3.Options)) (*s3.HeadObjectOutput, error)
	PutObject(ctx context.Context, params *s3.PutObjectInput, optFns ...func(*s3.Options)) (*s3.PutObjectOutput, error)
	ListObjectsV2(ctx context.Context, params *s3.ListObjectsV2Input, optFns ...func(*s3.Options)) (*s3.ListObjectsV2Output, error)
}

Client defines methods implemented by AWS SDK for Go v2's S3 client.

type MockClient

type MockClient struct {

	// For testing: if MockError is set, any S3ClientAPI function called will return that error
	MockError error
	// For testing: enable pagination
	PaginateListResults bool
	// For testing: disable object copying
	DisableObjectCopying bool
	// For testing: disable object deleting
	DisableObjectDeleting bool
	// contains filtered or unexported fields
}

MockClient contains the components of an S3 mock client.

func NewMockClient

func NewMockClient(t *testing.T, baseURI storage.Path) (*MockClient, error)

NewMockClient creates a mock S3 client that uses a filestore in a temporary directory to store, retrieve, and manipulate files

func (*MockClient) CopyObject

func (m *MockClient) CopyObject(ctx context.Context, input *s3.CopyObjectInput, optFns ...func(*s3.Options)) (*s3.CopyObjectOutput, error)

CopyObject copies an object to a specified path.

func (*MockClient) DeleteObject

func (m *MockClient) DeleteObject(ctx context.Context, input *s3.DeleteObjectInput, optFns ...func(*s3.Options)) (*s3.DeleteObjectOutput, error)

DeleteObject removes an object from a bucket.

func (*MockClient) FileExists

func (m *MockClient) FileExists(baseURI storage.Path, location storage.Path) (bool, error)

FileExists checks if a file exists in the underlying filestore for use in unit tests

func (*MockClient) FileStore

func (m *MockClient) FileStore() *filestore.FileObjectStore

FileStore gets the file store.

func (*MockClient) GetFile

func (m *MockClient) GetFile(baseURI storage.Path, location storage.Path) ([]byte, error)

GetFile returns a file from the underlying filestore, for use in unit tests

func (*MockClient) GetObject

func (m *MockClient) GetObject(ctx context.Context, input *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)

GetObject retrieves an object.

func (*MockClient) HeadObject

func (m *MockClient) HeadObject(ctx context.Context, input *s3.HeadObjectInput, optFns ...func(*s3.Options)) (*s3.HeadObjectOutput, error)

HeadObject retrieves metadata from an object without returning the object itself.

func (*MockClient) ListObjectsV2

func (m *MockClient) ListObjectsV2(ctx context.Context, input *s3.ListObjectsV2Input, optFns ...func(*s3.Options)) (*s3.ListObjectsV2Output, error)

ListObjectsV2 lists objects in a bucket.

func (*MockClient) PutFile

func (m *MockClient) PutFile(baseURI storage.Path, location storage.Path, data []byte) error

PutFile writes data to a file in the underlying filestore for use in unit tests

func (*MockClient) PutObject

func (m *MockClient) PutObject(ctx context.Context, input *s3.PutObjectInput, optFns ...func(*s3.Options)) (*s3.PutObjectOutput, error)

PutObject adds an object to a bucket.

func (*MockClient) S3StorePath

func (m *MockClient) S3StorePath() string

S3StorePath gets the S3 store path.

func (*MockClient) SetFileStore

func (m *MockClient) SetFileStore(store *filestore.FileObjectStore)

SetFileStore sets the file store.

func (*MockClient) SetS3StorePath

func (m *MockClient) SetS3StorePath(path string)

SetS3StorePath sets the S3 store path.

Jump to

Keyboard shortcuts

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