s3steps

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UploadError            error
	CreateBucketError      error
	DeleteBucketError      error
	GetBucketLocationError error
	HeadObjectError        error
	DownloadError          error
	DeleteObjectError      error
)

Functions

func InitializeContext

func InitializeContext(ctx context.Context) context.Context

InitializeContext adds the s3 session to the context. The new context is returned because context is immutable.

Types

type ClientFunctions

type ClientFunctions interface {
	New(cfgs aws.Config) *s3.Client
	NewUploader(s3Client *s3.Client) *s3manager.Uploader
	Upload(
		ctx context.Context,
		s3Client *s3.Client,
		uploader *s3manager.Uploader,
		bucket, key, message string,
	) (*s3manager.UploadOutput, error)
	CreateBucket(ctx context.Context,
		s3Client *s3.Client,
		input *s3.CreateBucketInput,
	) (*s3.CreateBucketOutput, error)
	DeleteBucket(
		ctx context.Context,
		s3Client *s3.Client,
		input *s3.DeleteBucketInput,
	) (*s3.DeleteBucketOutput, error)
	GetBucketLocation(
		ctx context.Context,
		s3Client *s3.Client,
		input *s3.GetBucketLocationInput,
	) (*s3.GetBucketLocationOutput, error)
	HeadObject(
		ctx context.Context,
		s3Client *s3.Client,
		input *s3.HeadObjectInput,
	) (*s3.HeadObjectOutput, error)
	NewDownloader(s3Client *s3.Client) *s3manager.Downloader
	Download(
		ctx context.Context,
		s3Client *s3.Client,
		downloader *s3manager.Downloader,
		w io.WriterAt,
		input *s3.GetObjectInput,
	) (int64, error)
	DeleteObject(
		ctx context.Context,
		s3Client *s3.Client,
		input *s3.DeleteObjectInput,
	) (*s3.DeleteObjectOutput, error)
}

type ClientService

type ClientService struct{}

func NewS3ClientService

func NewS3ClientService() *ClientService

func (ClientService) CreateBucket

func (c ClientService) CreateBucket(
	ctx context.Context,
	s3Client *s3.Client,
	input *s3.CreateBucketInput,
) (*s3.CreateBucketOutput, error)

func (ClientService) DeleteBucket

func (c ClientService) DeleteBucket(
	ctx context.Context,
	s3Client *s3.Client,
	input *s3.DeleteBucketInput,
) (*s3.DeleteBucketOutput, error)

func (ClientService) DeleteObject

func (c ClientService) DeleteObject(
	ctx context.Context,
	s3Client *s3.Client,
	input *s3.DeleteObjectInput,
) (*s3.DeleteObjectOutput, error)

func (ClientService) Download

func (c ClientService) Download(
	ctx context.Context,
	s3Client *s3.Client,
	downloader *s3manager.Downloader,
	w io.WriterAt,
	input *s3.GetObjectInput,
) (int64, error)

func (ClientService) GetBucketLocation

func (c ClientService) GetBucketLocation(
	ctx context.Context,
	s3Client *s3.Client,
	input *s3.GetBucketLocationInput,
) (*s3.GetBucketLocationOutput, error)

func (ClientService) HeadObject

func (c ClientService) HeadObject(
	ctx context.Context,
	s3Client *s3.Client,
	input *s3.HeadObjectInput,
) (*s3.HeadObjectOutput, error)

func (ClientService) New

func (c ClientService) New(cfgs aws.Config) *s3.Client

func (ClientService) NewDownloader

func (c ClientService) NewDownloader(s3Client *s3.Client) *s3manager.Downloader

func (ClientService) NewUploader

func (c ClientService) NewUploader(s3Client *s3.Client) *s3manager.Uploader

func (ClientService) Upload

func (c ClientService) Upload(
	ctx context.Context,
	s3Client *s3.Client,
	uploader *s3manager.Uploader,
	bucket, key, message string,
) (*s3manager.UploadOutput, error)

type ClientServiceFuncMock

type ClientServiceFuncMock struct{}

func (ClientServiceFuncMock) CreateBucket

func (c ClientServiceFuncMock) CreateBucket(ctx context.Context,
	s3Client *s3.Client,
	input *s3.CreateBucketInput,
) (*s3.CreateBucketOutput, error)

func (ClientServiceFuncMock) DeleteBucket

func (c ClientServiceFuncMock) DeleteBucket(
	ctx context.Context,
	s3Client *s3.Client,
	input *s3.DeleteBucketInput,
) (*s3.DeleteBucketOutput, error)

func (ClientServiceFuncMock) DeleteObject

func (c ClientServiceFuncMock) DeleteObject(
	ctx context.Context,
	s3Client *s3.Client,
	input *s3.DeleteObjectInput,
) (*s3.DeleteObjectOutput, error)

func (ClientServiceFuncMock) Download

func (c ClientServiceFuncMock) Download(
	ctx context.Context,
	s3Client *s3.Client,
	downloader *s3manager.Downloader,
	w io.WriterAt,
	input *s3.GetObjectInput,
) (int64, error)

func (ClientServiceFuncMock) GetBucketLocation

func (c ClientServiceFuncMock) GetBucketLocation(
	ctx context.Context,
	s3Client *s3.Client,
	input *s3.GetBucketLocationInput,
) (*s3.GetBucketLocationOutput, error)

func (ClientServiceFuncMock) HeadObject

func (c ClientServiceFuncMock) HeadObject(
	ctx context.Context,
	s3Client *s3.Client,
	input *s3.HeadObjectInput,
) (*s3.HeadObjectOutput, error)

func (ClientServiceFuncMock) New

func (c ClientServiceFuncMock) New(cfgs aws.Config) *s3.Client

func (ClientServiceFuncMock) NewDownloader

func (c ClientServiceFuncMock) NewDownloader(s3Client *s3.Client) *s3manager.Downloader

func (ClientServiceFuncMock) NewUploader

func (c ClientServiceFuncMock) NewUploader(s3Client *s3.Client) *s3manager.Uploader

func (ClientServiceFuncMock) Upload

func (c ClientServiceFuncMock) Upload(
	ctx context.Context,
	s3Client *s3.Client,
	uploader *s3manager.Uploader,
	bucket, key, message string,
) (*s3manager.UploadOutput, error)

type ContextKey

type ContextKey string

ContextKey defines a type to store the s3 session in context.Context.

type CreatedBucket

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

type CreatedDocument

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

type Logger

type Logger struct {
	Log *golium.Logger
}

Logger logs in a configurable file.

func GetLogger

func GetLogger() *Logger

GetLogger returns the logger for s3 operations. If the logger is not created yet, it creates a new instance of Logger.

func (Logger) LogMessage

func (l Logger) LogMessage(message string)

Log a S3 message

func (Logger) LogOperation

func (l Logger) LogOperation(operation, bucket, key string)

Log a S3 operation

type Session

type Session struct {
	Client           *s3.Client
	CreatedBuckets   []*CreatedBucket
	CreatedDocuments []*CreatedDocument
	S3ServiceClient  ClientFunctions
}

func GetSession

func GetSession(ctx context.Context) *Session

GetSession returns the s3 session stored in context. Note that the context should be previously initialized with InitializeContext function.

func (*Session) CleanUp

func (s *Session) CleanUp(ctx context.Context)

CleanUp cleans session by deleting all documents created in S3

func (*Session) CreateS3Bucket

func (s *Session) CreateS3Bucket(ctx context.Context, bucket string) error

CreateS3Bucket creates a new bucket.

func (*Session) DeleteS3Bucket

func (s *Session) DeleteS3Bucket(ctx context.Context, bucket string) error

DeleteS3Bucket deletes the bucket in S3.

func (*Session) DeleteS3File

func (s *Session) DeleteS3File(ctx context.Context, bucket, key string) error

DeleteS3File deletes the file in S3.

func (*Session) NewS3Session

func (s *Session) NewS3Session(ctx context.Context) error

NewS3Session initiates a new aws session.

func (*Session) UploadS3FileWithContent

func (s *Session) UploadS3FileWithContent(ctx context.Context, bucket, key, message string) error

UploadS3FileWithContent creates a new file in S3 with the content specified.

func (*Session) ValidateS3BucketExists

func (s *Session) ValidateS3BucketExists(ctx context.Context, bucket string) error

ValidateS3BucketExists verifies the existence of a bucket.

func (*Session) ValidateS3FileExists

func (s *Session) ValidateS3FileExists(ctx context.Context, bucket, key string) error

ValidateS3FileExists checks the existence of a file in S3.

func (*Session) ValidateS3FileExistsWithContent

func (s *Session) ValidateS3FileExistsWithContent(
	ctx context.Context,
	bucket, key, message string,
) error

ValidateS3FileWithContent checks the existence of a file in S3 with the content specified.

type Steps

type Steps struct {
}

Steps to initialize common steps.

func (Steps) InitializeSteps

func (cs Steps) InitializeSteps(ctx context.Context, scenCtx *godog.ScenarioContext) context.Context

InitializeSteps initializes all the steps to work with S3. It implements StepsInitializer interface.

Jump to

Keyboard shortcuts

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