Documentation ¶
Overview ¶
Package s3utils implements utilities used to interact with S3.
Package s3utils implements utilities used to interact with S3.
Index ¶
- type Client
- type MockClient
- func (m *MockClient) CopyObject(ctx context.Context, input *s3.CopyObjectInput, optFns ...func(*s3.Options)) (*s3.CopyObjectOutput, error)
- func (m *MockClient) DeleteObject(ctx context.Context, input *s3.DeleteObjectInput, optFns ...func(*s3.Options)) (*s3.DeleteObjectOutput, error)
- func (m *MockClient) FileExists(baseURI storage.Path, location storage.Path) (bool, error)
- func (m *MockClient) FileStore() *filestore.FileObjectStore
- func (m *MockClient) GetFile(baseURI storage.Path, location storage.Path) ([]byte, error)
- func (m *MockClient) GetObject(ctx context.Context, input *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)
- func (m *MockClient) HeadObject(ctx context.Context, input *s3.HeadObjectInput, optFns ...func(*s3.Options)) (*s3.HeadObjectOutput, error)
- func (m *MockClient) ListObjectsV2(ctx context.Context, input *s3.ListObjectsV2Input, optFns ...func(*s3.Options)) (*s3.ListObjectsV2Output, error)
- func (m *MockClient) PutFile(baseURI storage.Path, location storage.Path, data []byte) error
- func (m *MockClient) PutObject(ctx context.Context, input *s3.PutObjectInput, optFns ...func(*s3.Options)) (*s3.PutObjectOutput, error)
- func (m *MockClient) S3StorePath() string
- func (m *MockClient) SetFileStore(store *filestore.FileObjectStore)
- func (m *MockClient) SetS3StorePath(path string)
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 ¶
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 ¶
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 ¶
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 ¶
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.