s3

package
v0.0.0-...-b600c66 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildMeta

func BuildMeta(meta *ExportMeta) ([]byte, error)

func BuildReadme

func BuildReadme(meta *ExportMeta) (string, error)

func GetObject

func GetObject(c context.Context, api S3GetObjectAPI, input *s3.GetObjectInput) (*s3.GetObjectOutput, error)

GetObject retrieves objects from Amazon S3

func NewS3Client

func NewS3Client(cfg econfig.ExportConfig, log *zap.SugaredLogger) *s3.Client

Types

type Compressor

type Compressor struct {
	Bucket string
	Log    *zap.SugaredLogger
	Client s3.Client
	Cfg    econfig.ExportConfig
}

func (*Compressor) Compress

func (*Compressor) CreateObject

func (c *Compressor) CreateObject(ctx context.Context, db models.DBInterface, body io.Reader, application string, resourceUUID uuid.UUID, payload *models.ExportPayload) error

func (*Compressor) Download

func (c *Compressor) Download(ctx context.Context, w io.WriterAt, bucket, key *string) (n int64, err error)

func (*Compressor) GetObject

func (c *Compressor) GetObject(ctx context.Context, key string) (io.ReadCloser, error)

func (*Compressor) ProcessSources

func (c *Compressor) ProcessSources(db models.DBInterface, uid uuid.UUID)

func (*Compressor) Upload

func (c *Compressor) Upload(ctx context.Context, body io.Reader, bucket, key *string) (*manager.UploadOutput, error)

type ExportError

type ExportError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type ExportFileMeta

type ExportFileMeta struct {
	Filename    string `json:"filename"`
	Application string `json:"application"`
	Resource    string `json:"resource"`
	// Filters are a key-value pair of the filters used to create the export
	Filters map[string]string `json:"filters"`
}

details for each file in the tar

type ExportMeta

type ExportMeta struct {
	ExportBy    string           `json:"exported_by"`
	ExportDate  string           `json:"export_date"`
	ExportOrgID string           `json:"export_org_id"`
	FileMeta    []ExportFileMeta `json:"file_meta"`
	HelpString  string           `json:"help_string"`
	FailedFiles []FailedFileMeta `json:"failed_files,omitempty"`
}

struct used to fill the README.md and meta.json files in the tar

type FailedFileMeta

type FailedFileMeta struct {
	Filename    string      `json:"filename"`
	Application string      `json:"application"`
	Resource    string      `json:"resource"`
	Error       ExportError `json:"error"`
}

type MockStorageHandler

type MockStorageHandler struct {
}

func (*MockStorageHandler) Compress

func (*MockStorageHandler) CreateObject

func (mc *MockStorageHandler) CreateObject(ctx context.Context, db models.DBInterface, body io.Reader, application string, resourceUUID uuid.UUID, payload *models.ExportPayload) error

func (*MockStorageHandler) Download

func (mc *MockStorageHandler) Download(ctx context.Context, w io.WriterAt, bucket, key *string) (n int64, err error)

func (*MockStorageHandler) GetObject

func (mc *MockStorageHandler) GetObject(ctx context.Context, key string) (io.ReadCloser, error)

func (*MockStorageHandler) ProcessSources

func (mc *MockStorageHandler) ProcessSources(db models.DBInterface, uid uuid.UUID)

func (*MockStorageHandler) Upload

func (mc *MockStorageHandler) Upload(ctx context.Context, body io.Reader, bucket, key *string) (*manager.UploadOutput, error)

type S3GetObjectAPI

type S3GetObjectAPI interface {
	GetObject(ctx context.Context,
		params *s3.GetObjectInput,
		optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)
}

S3GetObjectAPI defines the interface for the GetObject function. We use this interface to test the function using a mocked service.

type S3ListObjectsAPI

type S3ListObjectsAPI interface {
	ListObjectsV2(ctx context.Context,
		params *s3.ListObjectsV2Input,
		optFns ...func(*s3.Options)) (*s3.ListObjectsV2Output, error)
}

S3ListObjectsAPI defines the interface for the ListObjectsV2 function. We use this interface to test the function using a mocked service. https://aws.github.io/aws-sdk-go-v2/docs/code-examples/s3/listobjects/

type StorageHandler

type StorageHandler interface {
	Compress(ctx context.Context, m *models.ExportPayload) (time.Time, string, string, error)
	Download(ctx context.Context, w io.WriterAt, bucket, key *string) (n int64, err error)
	Upload(ctx context.Context, body io.Reader, bucket, key *string) (*manager.UploadOutput, error)
	CreateObject(ctx context.Context, db models.DBInterface, body io.Reader, application string, resourceUUID uuid.UUID, payload *models.ExportPayload) error
	GetObject(ctx context.Context, key string) (io.ReadCloser, error)
	ProcessSources(db models.DBInterface, uid uuid.UUID)
}

Jump to

Keyboard shortcuts

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