s3

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// BucketNotFoundErrCode is the error code sent by AWS when a bucket does not exist
	BucketNotFoundErrCode = "NotFound"
	// CORSNotFoundErrCode is the error code sent by AWS when the CORS configuration does not exist
	CORSNotFoundErrCode = "NoSuchCORSConfiguration"
	// PublicAccessBlockNotFoundErrCode is NotFound error for PublicAccessBlock
	PublicAccessBlockNotFoundErrCode = "NoSuchPublicAccessBlockConfiguration"
	// ReplicationNotFoundErrCode is the error code sent by AWS when the replication config does not exist
	ReplicationNotFoundErrCode = "ReplicationConfigurationNotFoundError"
	// LifecycleNotFoundErrCode is the error code sent by AWS when the lifecycle config does not exist
	LifecycleNotFoundErrCode = "NoSuchLifecycleConfiguration"
	// SSENotFoundErrCode is the error code sent by AWS when the SSE config does not exist
	SSENotFoundErrCode = "ServerSideEncryptionConfigurationNotFoundError"
	// TaggingNotFoundErrCode is the error code sent by AWS when the tagging does not exist
	TaggingNotFoundErrCode = "NoSuchTagSet"
	// WebsiteNotFoundErrCode is the error code sent by AWS when the website config does not exist
	WebsiteNotFoundErrCode = "NoSuchWebsiteConfiguration"

	// MethodNotAllowed is the error code sent by AWS when the request method for an object is not allowed
	MethodNotAllowed = "MethodNotAllowed"
	// UnsupportedArgument is the error code sent by AWS when the request fields contain an argument that is not supported
	UnsupportedArgument = "UnsupportedArgument"
)

See - https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html#RESTErrorResponses

Functions

func ArgumentNotSupported

func ArgumentNotSupported(err error) bool

ArgumentNotSupported is parses the aws Error and validates if parameters are now allowed for a request

func BucketHasACLsDisabled added in v0.29.0

func BucketHasACLsDisabled(bucket *v1beta1.Bucket) bool

BucketHasACLsDisabled returns true if ACLs are disabled for the bucket, i.e., if ObjectOwnership is set to BucketOwnerEnforced

func CORSConfigurationNotFound

func CORSConfigurationNotFound(err error) bool

CORSConfigurationNotFound is parses the aws Error and validates if the cors configuration does not exist

func CopyAWSTags

func CopyAWSTags(tags []s3types.Tag) []v1beta1.Tag

CopyAWSTags converts a list of external s3.Tags to local Tags

func CopyTags

func CopyTags(tags []v1beta1.Tag) []s3types.Tag

CopyTags converts a list of local v1beta.Tags to S3 Tags

func GenerateBucketObservation

func GenerateBucketObservation(name string, partition string) v1beta1.BucketExternalStatus

GenerateBucketObservation generates the ARN string for the external status

func GenerateCreateBucketInput

func GenerateCreateBucketInput(name string, s v1beta1.BucketParameters) *s3.CreateBucketInput

GenerateCreateBucketInput creates the input for CreateBucket S3 Client request

func IsAlreadyExists

func IsAlreadyExists(err error) bool

IsAlreadyExists helper function to test for ErrCodeBucketAlreadyOwnedByYou error

func IsErrorBucketNotFound

func IsErrorBucketNotFound(err error) bool

IsErrorBucketNotFound returns true if the error code indicates that the bucket was not found

func IsErrorPolicyNotFound

func IsErrorPolicyNotFound(err error) bool

IsErrorPolicyNotFound returns true if the error code indicates that the item was not found

func IsNotFound

func IsNotFound(err error) bool

IsNotFound helper function to test for NotFound error

func LifecycleConfigurationNotFound

func LifecycleConfigurationNotFound(err error) bool

LifecycleConfigurationNotFound is parses the aws Error and validates if the lifecycle configuration does not exist

func MethodNotSupported

func MethodNotSupported(err error) bool

MethodNotSupported is parses the aws Error and validates if the method is allowed for a request

func PublicAccessBlockConfigurationNotFound

func PublicAccessBlockConfigurationNotFound(err error) bool

PublicAccessBlockConfigurationNotFound is parses the aws Error and validates if the public access block does not exist

func ReplicationConfigurationNotFound

func ReplicationConfigurationNotFound(err error) bool

ReplicationConfigurationNotFound is parses the aws Error and validates if the replication configuration does not exist

func SSEConfigurationNotFound

func SSEConfigurationNotFound(err error) bool

SSEConfigurationNotFound is parses the aws Error and validates if the SSE configuration does not exist

func Serialize

func Serialize(p *v1alpha3.BucketPolicyBody) (interface{}, error)

Serialize is the custom marshaller for the BucketPolicyParameters

func SerializeAWSPrincipal

func SerializeAWSPrincipal(p v1alpha3.AWSPrincipal) *string

SerializeAWSPrincipal converts an AWSPrincipal to a string

func SerializeBucketCondition

func SerializeBucketCondition(p []v1alpha3.Condition) (interface{}, error)

SerializeBucketCondition converts the string -> Condition map into a serialized version

func SerializeBucketPolicyStatement

func SerializeBucketPolicyStatement(p v1alpha3.BucketPolicyStatement) (interface{}, error)

SerializeBucketPolicyStatement is the custom marshaller for the BucketPolicyStatement

func SerializeBucketPrincipal

func SerializeBucketPrincipal(p *v1alpha3.BucketPrincipal) (interface{}, error)

SerializeBucketPrincipal is the custom serializer for the BucketPrincipal

func SortS3TagSet

func SortS3TagSet(tags []s3types.Tag) []s3types.Tag

SortS3TagSet stable sorts an external s3 tag list by the key and value.

func TaggingNotFound

func TaggingNotFound(err error) bool

TaggingNotFound is parses the aws Error and validates if the tagging configuration does not exist

func UpdateBucketACL

func UpdateBucketACL(ctx context.Context, client BucketClient, bucket *v1beta1.Bucket) error

UpdateBucketACL creates the ACLInput, sends the request to put an ACL based on the bucket

func UpdateBucketOwnershipControls added in v0.29.0

func UpdateBucketOwnershipControls(ctx context.Context, client BucketClient, bucket *v1beta1.Bucket) error

UpdateBucketOwnershipControls creates the OwnershipContolsInput, sends the request to put an ObjectOwnership based on the bucket

func WebsiteConfigurationNotFound

func WebsiteConfigurationNotFound(err error) bool

WebsiteConfigurationNotFound is parses the aws Error and validates if the website configuration does not exist

Types

type BucketClient

type BucketClient interface {
	HeadBucket(ctx context.Context, input *s3.HeadBucketInput, opts ...func(*s3.Options)) (*s3.HeadBucketOutput, error)
	CreateBucket(ctx context.Context, input *s3.CreateBucketInput, opts ...func(*s3.Options)) (*s3.CreateBucketOutput, error)
	DeleteBucket(ctx context.Context, input *s3.DeleteBucketInput, opts ...func(*s3.Options)) (*s3.DeleteBucketOutput, error)

	PutBucketEncryption(ctx context.Context, input *s3.PutBucketEncryptionInput, opts ...func(*s3.Options)) (*s3.PutBucketEncryptionOutput, error)
	GetBucketEncryption(ctx context.Context, input *s3.GetBucketEncryptionInput, opts ...func(*s3.Options)) (*s3.GetBucketEncryptionOutput, error)
	DeleteBucketEncryption(ctx context.Context, input *s3.DeleteBucketEncryptionInput, opts ...func(*s3.Options)) (*s3.DeleteBucketEncryptionOutput, error)

	PutBucketVersioning(ctx context.Context, input *s3.PutBucketVersioningInput, opts ...func(*s3.Options)) (*s3.PutBucketVersioningOutput, error)
	GetBucketVersioning(ctx context.Context, input *s3.GetBucketVersioningInput, opts ...func(*s3.Options)) (*s3.GetBucketVersioningOutput, error)

	PutBucketAccelerateConfiguration(ctx context.Context, input *s3.PutBucketAccelerateConfigurationInput, opts ...func(*s3.Options)) (*s3.PutBucketAccelerateConfigurationOutput, error)
	GetBucketAccelerateConfiguration(ctx context.Context, input *s3.GetBucketAccelerateConfigurationInput, opts ...func(*s3.Options)) (*s3.GetBucketAccelerateConfigurationOutput, error)

	PutBucketCors(ctx context.Context, input *s3.PutBucketCorsInput, opts ...func(*s3.Options)) (*s3.PutBucketCorsOutput, error)
	GetBucketCors(ctx context.Context, input *s3.GetBucketCorsInput, opts ...func(*s3.Options)) (*s3.GetBucketCorsOutput, error)
	DeleteBucketCors(ctx context.Context, input *s3.DeleteBucketCorsInput, opts ...func(*s3.Options)) (*s3.DeleteBucketCorsOutput, error)

	PutBucketWebsite(ctx context.Context, input *s3.PutBucketWebsiteInput, opts ...func(*s3.Options)) (*s3.PutBucketWebsiteOutput, error)
	GetBucketWebsite(ctx context.Context, input *s3.GetBucketWebsiteInput, opts ...func(*s3.Options)) (*s3.GetBucketWebsiteOutput, error)
	DeleteBucketWebsite(ctx context.Context, input *s3.DeleteBucketWebsiteInput, opts ...func(*s3.Options)) (*s3.DeleteBucketWebsiteOutput, error)

	PutBucketLogging(ctx context.Context, input *s3.PutBucketLoggingInput, opts ...func(*s3.Options)) (*s3.PutBucketLoggingOutput, error)
	GetBucketLogging(ctx context.Context, input *s3.GetBucketLoggingInput, opts ...func(*s3.Options)) (*s3.GetBucketLoggingOutput, error)

	PutBucketReplication(ctx context.Context, input *s3.PutBucketReplicationInput, opts ...func(*s3.Options)) (*s3.PutBucketReplicationOutput, error)
	GetBucketReplication(ctx context.Context, input *s3.GetBucketReplicationInput, opts ...func(*s3.Options)) (*s3.GetBucketReplicationOutput, error)
	DeleteBucketReplication(ctx context.Context, input *s3.DeleteBucketReplicationInput, opts ...func(*s3.Options)) (*s3.DeleteBucketReplicationOutput, error)

	PutBucketRequestPayment(ctx context.Context, input *s3.PutBucketRequestPaymentInput, opts ...func(*s3.Options)) (*s3.PutBucketRequestPaymentOutput, error)
	GetBucketRequestPayment(ctx context.Context, input *s3.GetBucketRequestPaymentInput, opts ...func(*s3.Options)) (*s3.GetBucketRequestPaymentOutput, error)

	PutBucketTagging(ctx context.Context, input *s3.PutBucketTaggingInput, opts ...func(*s3.Options)) (*s3.PutBucketTaggingOutput, error)
	GetBucketTagging(ctx context.Context, input *s3.GetBucketTaggingInput, opts ...func(*s3.Options)) (*s3.GetBucketTaggingOutput, error)
	DeleteBucketTagging(ctx context.Context, input *s3.DeleteBucketTaggingInput, opts ...func(*s3.Options)) (*s3.DeleteBucketTaggingOutput, error)

	PutBucketAnalyticsConfiguration(ctx context.Context, input *s3.PutBucketAnalyticsConfigurationInput, opts ...func(*s3.Options)) (*s3.PutBucketAnalyticsConfigurationOutput, error)
	GetBucketAnalyticsConfiguration(ctx context.Context, input *s3.GetBucketAnalyticsConfigurationInput, opts ...func(*s3.Options)) (*s3.GetBucketAnalyticsConfigurationOutput, error)

	PutBucketLifecycleConfiguration(ctx context.Context, input *s3.PutBucketLifecycleConfigurationInput, opts ...func(*s3.Options)) (*s3.PutBucketLifecycleConfigurationOutput, error)
	GetBucketLifecycleConfiguration(ctx context.Context, input *s3.GetBucketLifecycleConfigurationInput, opts ...func(*s3.Options)) (*s3.GetBucketLifecycleConfigurationOutput, error)
	DeleteBucketLifecycle(ctx context.Context, input *s3.DeleteBucketLifecycleInput, opts ...func(*s3.Options)) (*s3.DeleteBucketLifecycleOutput, error)

	PutBucketNotificationConfiguration(ctx context.Context, input *s3.PutBucketNotificationConfigurationInput, opts ...func(*s3.Options)) (*s3.PutBucketNotificationConfigurationOutput, error)
	GetBucketNotificationConfiguration(ctx context.Context, input *s3.GetBucketNotificationConfigurationInput, opts ...func(*s3.Options)) (*s3.GetBucketNotificationConfigurationOutput, error)

	GetBucketAcl(ctx context.Context, input *s3.GetBucketAclInput, opts ...func(*s3.Options)) (*s3.GetBucketAclOutput, error) //nolint
	PutBucketAcl(ctx context.Context, input *s3.PutBucketAclInput, opts ...func(*s3.Options)) (*s3.PutBucketAclOutput, error) //nolint
	GetPublicAccessBlock(ctx context.Context, input *s3.GetPublicAccessBlockInput, opts ...func(*s3.Options)) (*s3.GetPublicAccessBlockOutput, error)
	PutPublicAccessBlock(ctx context.Context, input *s3.PutPublicAccessBlockInput, opts ...func(*s3.Options)) (*s3.PutPublicAccessBlockOutput, error)
	DeletePublicAccessBlock(ctx context.Context, input *s3.DeletePublicAccessBlockInput, opts ...func(*s3.Options)) (*s3.DeletePublicAccessBlockOutput, error)

	GetBucketOwnershipControls(ctx context.Context, input *s3.GetBucketOwnershipControlsInput, opts ...func(*s3.Options)) (*s3.GetBucketOwnershipControlsOutput, error)
	PutBucketOwnershipControls(ctx context.Context, input *s3.PutBucketOwnershipControlsInput, opts ...func(*s3.Options)) (*s3.PutBucketOwnershipControlsOutput, error)
	DeleteBucketOwnershipControls(ctx context.Context, input *s3.DeleteBucketOwnershipControlsInput, opts ...func(*s3.Options)) (*s3.DeleteBucketOwnershipControlsOutput, error)
}

BucketClient is the interface for Client for making S3 Bucket requests.

func NewClient

func NewClient(cfg aws.Config) BucketClient

NewClient returns a new client using AWS credentials as JSON encoded data.

type BucketPolicyClient

type BucketPolicyClient interface {
	GetBucketPolicy(ctx context.Context, input *s3.GetBucketPolicyInput, opts ...func(*s3.Options)) (*s3.GetBucketPolicyOutput, error)
	PutBucketPolicy(ctx context.Context, input *s3.PutBucketPolicyInput, opts ...func(*s3.Options)) (*s3.PutBucketPolicyOutput, error)
	DeleteBucketPolicy(ctx context.Context, input *s3.DeleteBucketPolicyInput, opts ...func(*s3.Options)) (*s3.DeleteBucketPolicyOutput, error)
}

BucketPolicyClient is the external client used for S3BucketPolicy Custom Resource

func NewBucketPolicyClient

func NewBucketPolicyClient(cfg aws.Config) BucketPolicyClient

NewBucketPolicyClient returns a new client given an aws config

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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