s3storage

package
v0.20.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type S3Event added in v0.7.0

type S3Event struct {
	Records []S3EventRecord `json:"Records,omitempty"`
}

S3Event describes events received from S3 notification service. They are, kind of, documented here: https://docs.aws.amazon.com/AmazonS3/latest/dev/notification-content-structure.html

func (*S3Event) Unmarshal added in v0.7.0

func (p *S3Event) Unmarshal(data []byte) error

type S3EventRecord added in v0.7.0

type S3EventRecord struct {
	EventVersion      string                `json:"eventVersion,omitempty"`
	EventSource       string                `json:"eventSource,omitempty"`
	AwsRegion         string                `json:"awsRegion,omitempty"`
	EventTime         string                `json:"eventTime,omitempty"`
	EventName         string                `json:"eventName,omitempty"`
	UserIdentity      S3EventRecordIdentity `json:"userIdentity,omitempty"`
	RequestParameters map[string]string     `json:"requestParameters,omitempty"`
	ResponseElements  map[string]string     `json:"responseElements,omitempty"`
	S3                S3EventRecordData     `json:"s3,omitempty"`
}

type S3EventRecordData added in v0.7.0

type S3EventRecordData struct {
	S3SchemaVersion string                  `json:"s3SchemaVersion,omitempty"`
	ConfigurationId string                  `json:"configurationId,omitempty"`
	Bucket          S3EventRecordDataBucket `json:"bucket,omitempty"`
	Object          S3EventRecordDataObject `json:"object,omitempty"`
}

type S3EventRecordDataBucket added in v0.7.0

type S3EventRecordDataBucket struct {
	Name          string                `json:"name,omitempty"`
	OwnerIdentity S3EventRecordIdentity `json:"ownerIdentity,omitempty"`
	Arn           string                `json:"arn,omitempty"`
}

type S3EventRecordDataObject added in v0.7.0

type S3EventRecordDataObject struct {
	Key       string `json:"key,omitempty"`
	Size      int    `json:"size,omitempty"`
	ETag      string `json:"eTag,omitempty"`
	VersionID string `json:"versionId,omitempty"`
	Sequencer string `json:"sequencer,omitempty"`
}

type S3EventRecordIdentity added in v0.7.0

type S3EventRecordIdentity struct {
	PrincipalId string `json:"principalId,omitempty"`
}

type Service

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

func New

func New(bucketName string, s3client s3iface.S3API, sqsClient sqsiface.SQSAPI, tracer tracing.Tracer) (*Service, error)

func (*Service) ArtifactExists

func (f *Service) ArtifactExists(ctx context.Context, service, artifactID string) (bool, error)

func (*Service) ArtifactPaths

func (f *Service) ArtifactPaths(ctx context.Context, service string, environment string, branch string, artifactID string) (specPath string, resourcesPath string, close func(context.Context), err error)

func (*Service) ArtifactSpecification

func (f *Service) ArtifactSpecification(ctx context.Context, service string, artifactID string) (artifact.Spec, error)

func (*Service) ArtifactSpecifications

func (f *Service) ArtifactSpecifications(ctx context.Context, service string, n int, branch string) ([]artifact.Spec, error)

func (*Service) Close added in v0.7.0

func (s *Service) Close() error

Close closes the S3 storage service. Multiple calls to this method will result in a panic.

func (*Service) CreateArtifact

func (s *Service) CreateArtifact(artifactSpec artifact.Spec, md5 string) (string, error)

func (*Service) InitializeBucket

func (s *Service) InitializeBucket() error

func (*Service) InitializeSQS added in v0.7.0

func (s *Service) InitializeSQS(handler func(msg string) error) error

InitializeSQS set up a subscription from S3 to a SQS queue. The SQS queue events triggers calls to handler.InitializeSQS

Note on S3 notifications: There are 2 ways to get S3 notifications into SQS:

  • Directly from S3 Notification to SQS Queue
  • From S3 Notification to SNS Topic to SQS Queue

Using a SNS Topic should be more powerful, since it fx can send to multiple SQS Queues, but it requires more configuration and moving parts. The simpler model should suffice, therefore we connect it directly.k

func (*Service) LatestArtifactPaths

func (f *Service) LatestArtifactPaths(ctx context.Context, service string, environment string, branch string) (specPath string, resourcesPath string, close func(context.Context), err error)

func (*Service) LatestArtifactSpecification

func (f *Service) LatestArtifactSpecification(ctx context.Context, service string, branch string) (artifact.Spec, error)

Jump to

Keyboard shortcuts

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