s3

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 58 Imported by: 0

README

S3

Parity grade: B · SDK aws-sdk-go-v2/service/s3 · last audited 2026-07-11 (a007ec3e) · protocol REST-XML

Coverage

Metric Value
Operations audited 3 (3 ok)
Feature families 6 (6 ok)
Known gaps 2
Deferred items 0
Resource leaks clean
Known gaps
  • object_lambda dual-lock + no delete-on-bucket-delete (bd: s3 objectLambda follow-up)
  • abandoned multipart uploads have no per-upload TTL (only Abort/Complete/Purge)

More

Documentation

Index

Constants

View Source
const (
	ChecksumCRC32  = "CRC32"
	ChecksumCRC32C = "CRC32C"
	ChecksumSHA1   = "SHA1"
	ChecksumSHA256 = "SHA256"
)
View Source
const ChecksumCRC64NVME = "CRC64NVME"

ChecksumCRC64NVME is the algorithm name for CRC64/NVME checksums.

View Source
const NullVersion = "null"

NullVersion is the version ID used when versioning is not enabled.

Variables

View Source
var (
	ErrBucketAlreadyExists     = awserr.New("BucketAlreadyExists", awserr.ErrAlreadyExists)
	ErrBucketAlreadyOwnedByYou = awserr.New("BucketAlreadyOwnedByYou", awserr.ErrAlreadyExists)
	ErrNoSuchBucket            = awserr.New("NoSuchBucket", awserr.ErrNotFound)
	ErrNoSuchKey               = awserr.New("NoSuchKey", awserr.ErrNotFound)
	ErrInvalidBucketName       = errors.New("InvalidBucketName")
	ErrBucketNotEmpty          = errors.New(
		"BucketNotEmpty: The bucket you tried to delete is not empty",
	)
	ErrPermanentRedirect = errors.New("PermanentRedirect")
	// ErrPreconditionFailed is returned when an If-Match / If-None-Match
	// condition on a write op (PutObject / DeleteObject) fails.
	ErrPreconditionFailed         = errors.New("PreconditionFailed")
	ErrNotImplemented             = errors.New("NotImplemented")
	ErrMethodNotAllowed           = errors.New("MethodNotAllowed")
	ErrInvalidArgument            = errors.New(errInvalidArgument)
	ErrNoSuchUpload               = awserr.New("NoSuchUpload", awserr.ErrNotFound)
	ErrInvalidPart                = errors.New("InvalidPart")
	ErrInvalidPartOrder           = errors.New("InvalidPartOrder")
	ErrEmptyParts                 = errors.New("InvalidRequest")
	ErrNoCompressor               = errors.New("data is compressed but no compressor available")
	ErrNoBucketPolicy             = errors.New("NoSuchBucketPolicy")
	ErrNoCORSConfig               = errors.New("NoSuchCORSConfiguration")
	ErrNoLifecycleConfig          = errors.New("NoSuchLifecycleConfiguration")
	ErrNoObjectLockConfig         = errors.New("ObjectLockConfigurationNotFoundError")
	ErrNoWebsiteConfig            = errors.New("NoSuchWebsiteConfiguration")
	ErrNoEncryptionConfig         = errors.New("ServerSideEncryptionConfigurationNotFoundError")
	ErrObjectLocked               = errors.New(errAccessDenied)
	ErrInvalidObjectState         = errors.New("InvalidObjectState")
	ErrNoSuchObjectLockConfig     = awserr.New("NoSuchObjectLockConfiguration", awserr.ErrNotFound)
	ErrNoPublicAccessBlock        = errors.New("NoSuchPublicAccessBlockConfiguration")
	ErrNoOwnershipControls        = errors.New("OwnershipControlsNotFoundError")
	ErrNoReplicationConfig        = errors.New("ReplicationConfigurationNotFoundError")
	ErrNoAnalyticsConfig          = errors.New(errNoSuchConfig)
	ErrNoInventoryConfig          = errors.New(errNoSuchConfig)
	ErrNoMetricsConfig            = errors.New(errNoSuchConfig)
	ErrNoIntelligentTieringConfig = errors.New(errNoSuchConfig)
	ErrNoMetadataConfig           = errors.New(errNoSuchConfig)
	ErrNoMetadataTableConfig      = errors.New(errNoSuchConfig)
	ErrNoSuchTagSet               = errors.New("NoSuchTagSet")
	ErrBadChecksum                = errors.New("BadDigest")
	ErrDeleteMarker               = errors.New("DeleteMarker")
	ErrLatestDeleteMarker         = errors.New("LatestDeleteMarker")
	ErrTooManyTags                = errors.New("BadRequest")
	ErrInvalidTag                 = errors.New("InvalidTag")
	ErrCopySelfNoChange           = errors.New("CopySelfNoChange")
	ErrEntityTooSmall             = errors.New("EntityTooSmall")
	ErrAccessDenied               = errors.New(errAccessDenied)
	ErrKeyTooLongError            = errors.New("KeyTooLongError")
	ErrSSECRequired               = errors.New("InvalidRequest")
	// ErrMalformedXML is returned when an XML request body cannot be decoded.
	// The error table maps it to HTTP 400 with code "MalformedXML".
	ErrMalformedXML = errors.New(errMalformedXML)
)
View Source
var ErrRenameTargetSameAsSource = errors.New("target key must differ from source")

ErrRenameTargetSameAsSource is returned when RenameObject is called with a target key equal to (or empty relative to) the source key.

View Source
var ErrRestoreDaysNegative = errors.New("restore Days must be non-negative")

ErrRestoreDaysNegative is returned when RestoreObject is called with a negative Days value.

Functions

func CalculateCRC64NVME

func CalculateCRC64NVME(data []byte) string

CalculateCRC64NVME computes the base64-encoded CRC64/NVME checksum of data.

func CalculateChecksum

func CalculateChecksum(data []byte, algorithm string) string

func IsValidBucketName

func IsValidBucketName(name string) bool

IsValidBucketName validates an S3 bucket name based on AWS rules. Rules summary: - 3 to 63 characters long. - Only lowercase letters, numbers, dots (.), and hyphens (-). - Begins and ends with a letter or number. - No adjacent dots. - Not formatted as an IP address.

func IsValidObjectKey

func IsValidObjectKey(key string) bool

IsValidObjectKey validates an S3 object key based on AWS rules. Rules summary: - Up to 1024 bytes in UTF-8.

func NewCRC64NVME

func NewCRC64NVME() hash.Hash

NewCRC64NVME returns a new CRC64/NVME hash.

func WriteError

func WriteError(ctx context.Context, w http.ResponseWriter, r *http.Request, err error)

WriteError translates a typed Go error to an S3 ErrorResponse XML payload.

Types

type AccessControlList

type AccessControlList struct {
	Grants []Grant `xml:"Grant"`
}

AccessControlList contains the list of grants.

type AccessControlPolicy

type AccessControlPolicy struct {
	XMLName xml.Name          `xml:"AccessControlPolicy"`
	Xmlns   string            `xml:"xmlns,attr"`
	Owner   Owner             `xml:"Owner"`
	ACL     AccessControlList `xml:"AccessControlList"`
}

AccessControlPolicy is the XML response for GetBucketAcl.

type BucketLoggingStatus

type BucketLoggingStatus struct {
	LoggingEnabled *LoggingEnabled `xml:"LoggingEnabled,omitempty"`
	XMLName        xml.Name        `xml:"BucketLoggingStatus"`
	Xmlns          string          `xml:"xmlns,attr,omitempty"`
}

BucketLoggingStatus is the full XML body for PutBucketLogging / GetBucketLogging.

type BucketXML

type BucketXML struct {
	Name         string `xml:"Name"`
	CreationDate string `xml:"CreationDate"`
}

type CORSConfiguration

type CORSConfiguration struct {
	XMLName xml.Name   `xml:"CORSConfiguration"`
	Rules   []CORSRule `xml:"CORSRule"`
}

CORSConfiguration is the XML structure for a bucket's CORS configuration.

type CORSRule

type CORSRule struct {
	AllowedOrigins []string `xml:"AllowedOrigin"`
	AllowedMethods []string `xml:"AllowedMethod"`
	AllowedHeaders []string `xml:"AllowedHeader"`
	ExposeHeaders  []string `xml:"ExposeHeader"`
	MaxAgeSeconds  int      `xml:"MaxAgeSeconds,omitempty"`
}

CORSRule represents a single CORS rule within a CORSConfiguration.

type CommonPrefixXML

type CommonPrefixXML struct {
	Prefix string `xml:"Prefix"`
}

CommonPrefixXML represents a common prefix entry in a listing response.

type CompleteMultipartUpload

type CompleteMultipartUpload struct {
	XMLName xml.Name           `xml:"CompleteMultipartUpload"`
	Parts   []CompletedPartXML `xml:"Part"`
}

type CompleteMultipartUploadResult

type CompleteMultipartUploadResult struct {
	XMLName  xml.Name `xml:"CompleteMultipartUploadResult"`
	Location string   `xml:"Location"`
	Bucket   string   `xml:"Bucket"`
	Key      string   `xml:"Key"`
	ETag     string   `xml:"ETag"`
}

type CompletedPartXML

type CompletedPartXML struct {
	ETag       string `xml:"ETag"`
	PartNumber int    `xml:"PartNumber"`
}

type Compressor

type Compressor interface {
	Compress(data []byte) ([]byte, error)
	Decompress(data []byte) ([]byte, error)
}

type ConfigProvider

type ConfigProvider interface {
	GetS3Settings() Settings
	GetS3Endpoint() string
}

ConfigProvider is a private interface to extract S3 configuration from the abstract AppContext Config.

type CopyObjectResult

type CopyObjectResult struct {
	XMLName      xml.Name `xml:"CopyObjectResult"`
	ETag         string   `xml:"ETag"`
	LastModified string   `xml:"LastModified"`
}

type DashboardHandlers

type DashboardHandlers struct {
	HandleS3 func(http.ResponseWriter, *http.Request, string)
}

DashboardHandlers defines the functions needed for S3 dashboard routes.

type DashboardProvider

type DashboardProvider struct {
	// Handlers will be set by the dashboard handler during initialization
	Handlers DashboardHandlers
}

DashboardProvider implements the service.DashboardProvider interface to enable S3 dashboard discovery and route registration. It wraps a reference to dashboard handler functions.

func NewDashboardProvider

func NewDashboardProvider() *DashboardProvider

NewDashboardProvider creates a new S3 dashboard provider. The handlers must be set by the dashboard initialization code before any routes are registered.

func (*DashboardProvider) DashboardName

func (p *DashboardProvider) DashboardName() string

DashboardName returns the user-facing name for the S3 dashboard tab.

func (*DashboardProvider) DashboardRoutePrefix

func (p *DashboardProvider) DashboardRoutePrefix() string

DashboardRoutePrefix returns the URL path prefix for S3 dashboard routes.

func (*DashboardProvider) RegisterDashboardRoutes

func (p *DashboardProvider) RegisterDashboardRoutes(
	group *echo.Group,
	_ any,
	_ string,
)

RegisterDashboardRoutes registers all S3 dashboard routes under the given Echo group. The group is mounted at /dashboard/s3 by the dashboard handler.

type DefaultRetention

type DefaultRetention struct {
	Mode  string `xml:"Mode"`
	Days  int    `xml:"Days,omitempty"`
	Years int    `xml:"Years,omitempty"`
}

DefaultRetention specifies the default retention settings for objects placed in the bucket.

type DeleteErrorXML

type DeleteErrorXML struct {
	VersionID *string `xml:"VersionId,omitempty"`
	Key       string  `xml:"Key"`
	Code      string  `xml:"Code"`
	Message   string  `xml:"Message"`
}

type DeleteMarkerReplication

type DeleteMarkerReplication struct {
	Status string `xml:"Status"`
}

DeleteMarkerReplication controls whether delete markers are replicated.

type DeleteMarkerXML

type DeleteMarkerXML struct {
	Owner        *Owner `xml:"Owner"`
	Key          string `xml:"Key"`
	VersionID    string `xml:"VersionId"`
	LastModified string `xml:"LastModified"`
	IsLatest     bool   `xml:"IsLatest"`
}

type DeleteObject

type DeleteObject struct {
	VersionID *string `xml:"VersionId,omitempty"`
	Key       string  `xml:"Key"`
}

type DeleteRequest

type DeleteRequest struct {
	XMLName xml.Name       `xml:"Delete"`
	Objects []DeleteObject `xml:"Object"`
	Quiet   bool           `xml:"Quiet"`
}

type DeleteResult

type DeleteResult struct {
	XMLName xml.Name         `xml:"DeleteResult"`
	Deleted []DeletedXML     `xml:"Deleted"`
	Errors  []DeleteErrorXML `xml:"Error"`
}

type DeletedXML

type DeletedXML struct {
	VersionID             *string `xml:"VersionId,omitempty"`
	DeleteMarkerVersionID *string `xml:"DeleteMarkerVersionId,omitempty"`
	Key                   string  `xml:"Key"`
	DeleteMarker          bool    `xml:"DeleteMarker,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	XMLName   xml.Name `xml:"Error"`
	Code      string   `xml:"Code"`
	Message   string   `xml:"Message"`
	Resource  string   `xml:"Resource"`
	RequestID string   `xml:"RequestId"`
}

type EventBridgePublisher

type EventBridgePublisher interface {
	PublishS3Event(ctx context.Context, source, detailType, detail string)
}

EventBridgePublisher publishes an S3 event to the default EventBridge event bus.

type Grant

type Grant struct {
	Grantee    Grantee `xml:"Grantee"`
	Permission string  `xml:"Permission"`
}

Grant is a single permission grant.

type Grantee

type Grantee struct {
	XmlnsXsi    string `xml:"xmlns:xsi,attr"`
	XsiType     string `xml:"xsi:type,attr"`
	ID          string `xml:"ID,omitempty"`
	DisplayName string `xml:"DisplayName,omitempty"`
	URI         string `xml:"URI,omitempty"`
}

Grantee identifies who is being granted permissions. A CanonicalUser grantee carries ID/DisplayName; a Group grantee (AllUsers / AuthenticatedUsers / LogDelivery) carries URI instead.

type GzipCompressor

type GzipCompressor struct{}

func (*GzipCompressor) Compress

func (c *GzipCompressor) Compress(data []byte) ([]byte, error)

func (*GzipCompressor) Decompress

func (c *GzipCompressor) Decompress(data []byte) ([]byte, error)

type InMemoryBackend

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

func NewInMemoryBackend

func NewInMemoryBackend(compressor Compressor) *InMemoryBackend

func (*InMemoryBackend) AbortMultipartUpload

func (*InMemoryBackend) BucketRegion

func (b *InMemoryBackend) BucketRegion(name string) string

BucketRegion returns the region a bucket is stored in, or "" if the bucket does not exist. Safe for concurrent use.

func (*InMemoryBackend) BucketsByRegion

func (b *InMemoryBackend) BucketsByRegion(region string) []types.Bucket

BucketsByRegion returns a snapshot of all Bucket SDK objects in the given region. Returns all buckets (cross-region) if region is empty.

func (*InMemoryBackend) CompleteMultipartUpload

func (*InMemoryBackend) CreateBucket

func (b *InMemoryBackend) CreateBucket(
	ctx context.Context,
	input *s3.CreateBucketInput,
) (*s3.CreateBucketOutput, error)

func (*InMemoryBackend) CreateBucketMetadataConfiguration

func (b *InMemoryBackend) CreateBucketMetadataConfiguration(
	_ context.Context,
	bucketName, configXML string,
) error

CreateBucketMetadataConfiguration stores the metadata configuration for a bucket.

func (*InMemoryBackend) CreateBucketMetadataTableConfiguration

func (b *InMemoryBackend) CreateBucketMetadataTableConfiguration(
	_ context.Context,
	bucketName, configXML string,
) error

CreateBucketMetadataTableConfiguration stores the metadata table configuration for a bucket.

func (*InMemoryBackend) CreateMultipartUpload

func (b *InMemoryBackend) CreateMultipartUpload(
	ctx context.Context,
	input *s3.CreateMultipartUploadInput,
) (*s3.CreateMultipartUploadOutput, error)

func (*InMemoryBackend) CreateSession

func (b *InMemoryBackend) CreateSession(_ context.Context, bucketName string) (string, error)

CreateSession returns a stub session response for a bucket (S3 Express One Zone).

func (*InMemoryBackend) DeleteBucket

func (b *InMemoryBackend) DeleteBucket(
	_ context.Context,
	input *s3.DeleteBucketInput,
) (*s3.DeleteBucketOutput, error)

func (*InMemoryBackend) DeleteBucketAnalyticsConfiguration

func (b *InMemoryBackend) DeleteBucketAnalyticsConfiguration(
	_ context.Context,
	bucketName, id string,
) error

DeleteBucketAnalyticsConfiguration removes an analytics configuration from a bucket by ID.

func (*InMemoryBackend) DeleteBucketCORS

func (b *InMemoryBackend) DeleteBucketCORS(_ context.Context, bucketName string) error

DeleteBucketCORS clears the bucket CORS configuration.

func (*InMemoryBackend) DeleteBucketEncryption

func (b *InMemoryBackend) DeleteBucketEncryption(_ context.Context, bucketName string) error

DeleteBucketEncryption clears the server-side encryption configuration for a bucket.

func (*InMemoryBackend) DeleteBucketIntelligentTieringConfiguration

func (b *InMemoryBackend) DeleteBucketIntelligentTieringConfiguration(
	_ context.Context,
	bucketName, id string,
) error

DeleteBucketIntelligentTieringConfiguration removes an Intelligent-Tiering configuration from a bucket by ID.

func (*InMemoryBackend) DeleteBucketInventoryConfiguration

func (b *InMemoryBackend) DeleteBucketInventoryConfiguration(
	_ context.Context,
	bucketName, id string,
) error

DeleteBucketInventoryConfiguration removes an inventory configuration from a bucket by ID.

func (*InMemoryBackend) DeleteBucketLifecycle

func (b *InMemoryBackend) DeleteBucketLifecycle(ctx context.Context, bucketName string) error

DeleteBucketLifecycle clears the lifecycle configuration for a bucket. This is the legacy alias for DeleteBucketLifecycleConfiguration.

func (*InMemoryBackend) DeleteBucketLifecycleConfiguration

func (b *InMemoryBackend) DeleteBucketLifecycleConfiguration(
	_ context.Context,
	bucketName string,
) error

DeleteBucketLifecycleConfiguration clears the lifecycle configuration for a bucket.

func (*InMemoryBackend) DeleteBucketMetadataConfiguration

func (b *InMemoryBackend) DeleteBucketMetadataConfiguration(
	_ context.Context,
	bucketName string,
) error

DeleteBucketMetadataConfiguration clears the metadata configuration for a bucket.

func (*InMemoryBackend) DeleteBucketMetadataTableConfiguration

func (b *InMemoryBackend) DeleteBucketMetadataTableConfiguration(
	_ context.Context,
	bucketName string,
) error

DeleteBucketMetadataTableConfiguration clears the metadata table configuration for a bucket.

func (*InMemoryBackend) DeleteBucketMetricsConfiguration

func (b *InMemoryBackend) DeleteBucketMetricsConfiguration(
	_ context.Context,
	bucketName, id string,
) error

DeleteBucketMetricsConfiguration removes a metrics configuration from a bucket by ID.

func (*InMemoryBackend) DeleteBucketOwnershipControls

func (b *InMemoryBackend) DeleteBucketOwnershipControls(
	_ context.Context,
	bucketName string,
) error

DeleteBucketOwnershipControls removes the ownership controls configuration for a bucket.

func (*InMemoryBackend) DeleteBucketPolicy

func (b *InMemoryBackend) DeleteBucketPolicy(_ context.Context, bucketName string) error

DeleteBucketPolicy clears the bucket policy document.

func (*InMemoryBackend) DeleteBucketReplication

func (b *InMemoryBackend) DeleteBucketReplication(_ context.Context, bucketName string) error

DeleteBucketReplication removes the replication configuration for a bucket.

func (*InMemoryBackend) DeleteBucketTagging

func (b *InMemoryBackend) DeleteBucketTagging(_ context.Context, bucketName string) error

DeleteBucketTagging removes the tag set from a bucket.

func (*InMemoryBackend) DeleteBucketWebsite

func (b *InMemoryBackend) DeleteBucketWebsite(_ context.Context, bucketName string) error

DeleteBucketWebsite clears the static website configuration for a bucket.

func (*InMemoryBackend) DeleteObject

func (b *InMemoryBackend) DeleteObject(
	ctx context.Context,
	input *s3.DeleteObjectInput,
) (*s3.DeleteObjectOutput, error)

func (*InMemoryBackend) DeleteObjectTagging

func (*InMemoryBackend) DeleteObjects

func (b *InMemoryBackend) DeleteObjects(
	_ context.Context,
	input *s3.DeleteObjectsInput,
) (*s3.DeleteObjectsOutput, error)

func (*InMemoryBackend) DeletePublicAccessBlock

func (b *InMemoryBackend) DeletePublicAccessBlock(_ context.Context, bucketName string) error

DeletePublicAccessBlock removes the public access block configuration for a bucket.

func (*InMemoryBackend) DrainReplicationGoroutines

func (b *InMemoryBackend) DrainReplicationGoroutines()

DrainReplicationGoroutines blocks until all in-flight replication goroutines complete. Use in tests to establish a happens-before boundary between operations that spawn replication goroutines and subsequent state assertions.

func (*InMemoryBackend) GetBucketACL

func (b *InMemoryBackend) GetBucketACL(_ context.Context, bucketName string) (string, error)

GetBucketACL returns the canned ACL for a bucket.

func (*InMemoryBackend) GetBucketAbac

func (b *InMemoryBackend) GetBucketAbac(_ context.Context, bucketName string) (string, error)

GetBucketAbac returns the stored ABAC configuration XML for a bucket. Returns an empty string (not an error) when no config has been set, matching the AWS behaviour of returning an empty AbacConfiguration element.

func (*InMemoryBackend) GetBucketAccelerateConfiguration

func (b *InMemoryBackend) GetBucketAccelerateConfiguration(
	_ context.Context,
	bucketName string,
) (string, error)

GetBucketAccelerateConfiguration returns the bucket's accelerate status. When unset the AWS default of "Suspended" is returned.

func (*InMemoryBackend) GetBucketAnalyticsConfiguration

func (b *InMemoryBackend) GetBucketAnalyticsConfiguration(
	_ context.Context,
	bucketName, id string,
) (string, error)

GetBucketAnalyticsConfiguration returns an analytics configuration for a bucket by ID.

func (*InMemoryBackend) GetBucketCORS

func (b *InMemoryBackend) GetBucketCORS(_ context.Context, bucketName string) (string, error)

GetBucketCORS returns the bucket CORS configuration.

func (*InMemoryBackend) GetBucketEncryption

func (b *InMemoryBackend) GetBucketEncryption(
	_ context.Context,
	bucketName string,
) (string, error)

GetBucketEncryption returns the server-side encryption configuration for a bucket.

func (*InMemoryBackend) GetBucketIntelligentTieringConfiguration

func (b *InMemoryBackend) GetBucketIntelligentTieringConfiguration(
	_ context.Context,
	bucketName, id string,
) (string, error)

GetBucketIntelligentTieringConfiguration returns an Intelligent-Tiering configuration for a bucket by ID.

func (*InMemoryBackend) GetBucketInventoryConfiguration

func (b *InMemoryBackend) GetBucketInventoryConfiguration(
	_ context.Context,
	bucketName, id string,
) (string, error)

GetBucketInventoryConfiguration returns an inventory configuration for a bucket by ID.

func (*InMemoryBackend) GetBucketLifecycleConfiguration

func (b *InMemoryBackend) GetBucketLifecycleConfiguration(
	_ context.Context,
	bucketName string,
) (string, error)

GetBucketLifecycleConfiguration returns the lifecycle configuration for a bucket.

func (*InMemoryBackend) GetBucketLogging

func (b *InMemoryBackend) GetBucketLogging(_ context.Context, bucketName string) (string, error)

GetBucketLogging returns the logging configuration for a bucket. Returns "" (empty string) when no logging is configured; the handler synthesizes the AWS-compatible empty XML response.

func (*InMemoryBackend) GetBucketMetadata

func (b *InMemoryBackend) GetBucketMetadata(
	_ context.Context,
	bucketName string,
) (string, string, []types.Tag, error)

func (*InMemoryBackend) GetBucketMetadataConfiguration

func (b *InMemoryBackend) GetBucketMetadataConfiguration(
	_ context.Context,
	bucketName string,
) (string, error)

GetBucketMetadataConfiguration returns the metadata configuration for a bucket.

func (*InMemoryBackend) GetBucketMetadataTableConfiguration

func (b *InMemoryBackend) GetBucketMetadataTableConfiguration(
	_ context.Context,
	bucketName string,
) (string, error)

GetBucketMetadataTableConfiguration returns the metadata table configuration for a bucket.

func (*InMemoryBackend) GetBucketMetricsConfiguration

func (b *InMemoryBackend) GetBucketMetricsConfiguration(
	_ context.Context,
	bucketName, id string,
) (string, error)

GetBucketMetricsConfiguration returns a metrics configuration for a bucket by ID.

func (*InMemoryBackend) GetBucketNotificationConfiguration

func (b *InMemoryBackend) GetBucketNotificationConfiguration(
	_ context.Context,
	bucketName string,
) (string, error)

GetBucketNotificationConfiguration returns the notification configuration for a bucket.

func (*InMemoryBackend) GetBucketOwnershipControls

func (b *InMemoryBackend) GetBucketOwnershipControls(
	_ context.Context,
	bucketName string,
) (string, error)

GetBucketOwnershipControls returns the ownership controls configuration for a bucket.

func (*InMemoryBackend) GetBucketPolicy

func (b *InMemoryBackend) GetBucketPolicy(_ context.Context, bucketName string) (string, error)

GetBucketPolicy returns the bucket policy document.

func (*InMemoryBackend) GetBucketReplication

func (b *InMemoryBackend) GetBucketReplication(
	_ context.Context,
	bucketName string,
) (string, error)

GetBucketReplication returns the replication configuration for a bucket.

func (*InMemoryBackend) GetBucketRequestPayment

func (b *InMemoryBackend) GetBucketRequestPayment(
	_ context.Context,
	bucketName string,
) (string, error)

GetBucketRequestPayment returns the request-payment payer; defaults to "BucketOwner".

func (*InMemoryBackend) GetBucketTagging

func (b *InMemoryBackend) GetBucketTagging(
	_ context.Context,
	bucketName string,
) ([]types.Tag, error)

GetBucketTagging returns the tag set for a bucket.

func (*InMemoryBackend) GetBucketVersioning

func (*InMemoryBackend) GetBucketWebsite

func (b *InMemoryBackend) GetBucketWebsite(_ context.Context, bucketName string) (string, error)

GetBucketWebsite returns the static website configuration for a bucket.

func (*InMemoryBackend) GetObject

func (b *InMemoryBackend) GetObject(
	ctx context.Context,
	input *s3.GetObjectInput,
) (*s3.GetObjectOutput, error)

func (*InMemoryBackend) GetObjectACL

func (b *InMemoryBackend) GetObjectACL(
	_ context.Context,
	bucketName, key, versionID string,
) (string, error)

GetObjectACL returns the persisted ACL XML for the targeted version, or "" when no explicit ACL has been set (caller should synthesise the default owner-FULL_CONTROL grant in that case).

func (*InMemoryBackend) GetObjectAttributes

func (b *InMemoryBackend) GetObjectAttributes(
	_ context.Context,
	bucketName, key, versionID string,
) (*ObjectAttributes, error)

GetObjectAttributes returns selected attributes for the latest version of an object. versionID may be empty to select the latest version.

func (*InMemoryBackend) GetObjectLegalHold

func (b *InMemoryBackend) GetObjectLegalHold(
	_ context.Context,
	bucketName, key string,
	versionID *string,
) (string, error)

GetObjectLegalHold returns the legal hold status for a specific object version.

func (*InMemoryBackend) GetObjectLockConfiguration

func (b *InMemoryBackend) GetObjectLockConfiguration(
	_ context.Context,
	bucketName string,
) (string, error)

GetObjectLockConfiguration retrieves the object lock configuration for a bucket.

func (*InMemoryBackend) GetObjectRetention

func (b *InMemoryBackend) GetObjectRetention(
	_ context.Context,
	bucketName, key string,
	versionID *string,
) (string, time.Time, error)

GetObjectRetention returns the retention mode and retain-until-date for a specific object version.

func (*InMemoryBackend) GetObjectTagging

func (b *InMemoryBackend) GetObjectTagging(
	_ context.Context,
	input *s3.GetObjectTaggingInput,
) (*s3.GetObjectTaggingOutput, error)

func (*InMemoryBackend) GetPublicAccessBlock

func (b *InMemoryBackend) GetPublicAccessBlock(
	_ context.Context,
	bucketName string,
) (string, error)

GetPublicAccessBlock returns the public access block configuration for a bucket.

func (*InMemoryBackend) HeadBucket

func (b *InMemoryBackend) HeadBucket(
	_ context.Context,
	input *s3.HeadBucketInput,
) (*s3.HeadBucketOutput, error)

func (*InMemoryBackend) HeadObject

func (b *InMemoryBackend) HeadObject(
	ctx context.Context,
	input *s3.HeadObjectInput,
) (*s3.HeadObjectOutput, error)

func (*InMemoryBackend) ListBucketAnalyticsConfigurations

func (b *InMemoryBackend) ListBucketAnalyticsConfigurations(
	_ context.Context,
	bucketName string,
) ([]string, error)

ListBucketAnalyticsConfigurations returns all analytics configurations for a bucket.

func (*InMemoryBackend) ListBucketIntelligentTieringConfigurations

func (b *InMemoryBackend) ListBucketIntelligentTieringConfigurations(
	_ context.Context,
	bucketName string,
) ([]string, error)

ListBucketIntelligentTieringConfigurations returns all Intelligent-Tiering configurations for a bucket.

func (*InMemoryBackend) ListBucketInventoryConfigurations

func (b *InMemoryBackend) ListBucketInventoryConfigurations(
	_ context.Context,
	bucketName string,
) ([]string, error)

ListBucketInventoryConfigurations returns all inventory configurations for a bucket.

func (*InMemoryBackend) ListBucketMetricsConfigurations

func (b *InMemoryBackend) ListBucketMetricsConfigurations(
	_ context.Context,
	bucketName string,
) ([]string, error)

ListBucketMetricsConfigurations returns all metrics configurations for a bucket.

func (*InMemoryBackend) ListBuckets

func (*InMemoryBackend) ListDirectoryBuckets

func (b *InMemoryBackend) ListDirectoryBuckets(_ context.Context) ([]types.Bucket, error)

ListDirectoryBuckets returns all S3 Express directory buckets (name suffix --x-s3) owned by the account, excluding general-purpose buckets. Matches AWS behaviour where ListBuckets and ListDirectoryBuckets partition the two bucket types into separate lists.

func (*InMemoryBackend) ListMultipartUploads

ListMultipartUploads returns in-progress multipart uploads for a bucket.

func (*InMemoryBackend) ListObjectVersions

func (*InMemoryBackend) ListObjects

func (b *InMemoryBackend) ListObjects(
	_ context.Context,
	input *s3.ListObjectsInput,
) (*s3.ListObjectsOutput, error)

func (*InMemoryBackend) ListObjectsV2

func (b *InMemoryBackend) ListObjectsV2(
	ctx context.Context,
	input *s3.ListObjectsV2Input,
) (*s3.ListObjectsV2Output, error)

func (*InMemoryBackend) ListParts

func (b *InMemoryBackend) ListParts(
	_ context.Context,
	input *s3.ListPartsInput,
) (*s3.ListPartsOutput, error)

func (*InMemoryBackend) Purge

func (b *InMemoryBackend) Purge(ctx context.Context, cutoff time.Time)

Purge removes all buckets created before the given cutoff time.

func (*InMemoryBackend) PutBucketACL

func (b *InMemoryBackend) PutBucketACL(_ context.Context, bucketName, acl string) error

PutBucketACL stores the canned ACL for a bucket.

func (*InMemoryBackend) PutBucketAbac

func (b *InMemoryBackend) PutBucketAbac(_ context.Context, bucketName, configXML string) error

PutBucketAbac stores the ABAC configuration XML for an S3 Tables bucket.

func (*InMemoryBackend) PutBucketAccelerateConfiguration

func (b *InMemoryBackend) PutBucketAccelerateConfiguration(
	_ context.Context,
	bucketName, status string,
) error

PutBucketAccelerateConfiguration stores the accelerate status ("Enabled"/"Suspended") for a bucket.

func (*InMemoryBackend) PutBucketAnalyticsConfiguration

func (b *InMemoryBackend) PutBucketAnalyticsConfiguration(
	_ context.Context,
	bucketName, id, configXML string,
) error

PutBucketAnalyticsConfiguration stores an analytics configuration for a bucket by ID.

func (*InMemoryBackend) PutBucketCORS

func (b *InMemoryBackend) PutBucketCORS(_ context.Context, bucketName, corsXML string) error

PutBucketCORS stores the bucket CORS configuration.

func (*InMemoryBackend) PutBucketEncryption

func (b *InMemoryBackend) PutBucketEncryption(
	_ context.Context,
	bucketName, encryptionXML string,
) error

PutBucketEncryption stores the server-side encryption configuration for a bucket.

func (*InMemoryBackend) PutBucketIntelligentTieringConfiguration

func (b *InMemoryBackend) PutBucketIntelligentTieringConfiguration(
	_ context.Context,
	bucketName, id, configXML string,
) error

PutBucketIntelligentTieringConfiguration stores an Intelligent-Tiering configuration for a bucket by ID.

func (*InMemoryBackend) PutBucketInventoryConfiguration

func (b *InMemoryBackend) PutBucketInventoryConfiguration(
	_ context.Context,
	bucketName, id, configXML string,
) error

PutBucketInventoryConfiguration stores an inventory configuration for a bucket by ID.

func (*InMemoryBackend) PutBucketLifecycleConfiguration

func (b *InMemoryBackend) PutBucketLifecycleConfiguration(
	_ context.Context,
	bucketName, lifecycleXML string,
) error

PutBucketLifecycleConfiguration stores the lifecycle configuration for a bucket.

func (*InMemoryBackend) PutBucketLogging

func (b *InMemoryBackend) PutBucketLogging(_ context.Context, bucketName, loggingXML string) error

PutBucketLogging stores the logging configuration for a bucket.

func (*InMemoryBackend) PutBucketMetricsConfiguration

func (b *InMemoryBackend) PutBucketMetricsConfiguration(
	_ context.Context,
	bucketName, id, configXML string,
) error

PutBucketMetricsConfiguration stores a metrics configuration for a bucket by ID.

func (*InMemoryBackend) PutBucketNotificationConfiguration

func (b *InMemoryBackend) PutBucketNotificationConfiguration(
	_ context.Context,
	bucketName, notifXML string,
) error

func (*InMemoryBackend) PutBucketOwnershipControls

func (b *InMemoryBackend) PutBucketOwnershipControls(
	_ context.Context,
	bucketName, configXML string,
) error

PutBucketOwnershipControls stores the ownership controls configuration for a bucket.

func (*InMemoryBackend) PutBucketPolicy

func (b *InMemoryBackend) PutBucketPolicy(_ context.Context, bucketName, policy string) error

PutBucketPolicy stores the bucket policy document.

func (*InMemoryBackend) PutBucketReplication

func (b *InMemoryBackend) PutBucketReplication(
	_ context.Context,
	bucketName, replicationXML string,
) error

PutBucketReplication stores the replication configuration for a bucket.

func (*InMemoryBackend) PutBucketRequestPayment

func (b *InMemoryBackend) PutBucketRequestPayment(
	_ context.Context,
	bucketName, payer string,
) error

PutBucketRequestPayment stores the request-payment payer ("BucketOwner" or "Requester").

func (*InMemoryBackend) PutBucketTagging

func (b *InMemoryBackend) PutBucketTagging(
	_ context.Context,
	bucketName string,
	tags []types.Tag,
) error

PutBucketTagging sets the tag set for a bucket.

func (*InMemoryBackend) PutBucketVersioning

func (*InMemoryBackend) PutBucketWebsite

func (b *InMemoryBackend) PutBucketWebsite(_ context.Context, bucketName, websiteXML string) error

PutBucketWebsite stores the static website configuration for a bucket.

func (*InMemoryBackend) PutObject

func (b *InMemoryBackend) PutObject(
	ctx context.Context,
	input *s3.PutObjectInput,
) (*s3.PutObjectOutput, error)

func (*InMemoryBackend) PutObjectACL

func (b *InMemoryBackend) PutObjectACL(
	_ context.Context,
	bucketName, key, versionID, acl string,
) error

PutObjectACL stores the ACL XML/canned-ACL header on the latest object version. versionID may be empty to target the latest version.

func (*InMemoryBackend) PutObjectLegalHold

func (b *InMemoryBackend) PutObjectLegalHold(
	_ context.Context,
	bucketName, key string,
	versionID *string,
	status string,
) error

PutObjectLegalHold sets or clears the legal hold status for a specific object version.

func (*InMemoryBackend) PutObjectLockConfiguration

func (b *InMemoryBackend) PutObjectLockConfiguration(
	_ context.Context,
	bucketName, configXML string,
) error

PutObjectLockConfiguration stores the object lock configuration for a bucket.

func (*InMemoryBackend) PutObjectRetention

func (b *InMemoryBackend) PutObjectRetention(
	_ context.Context,
	bucketName, key string,
	versionID *string,
	mode string,
	retainUntil time.Time,
) error

PutObjectRetention sets the retention mode and retain-until-date for a specific object version.

func (*InMemoryBackend) PutObjectTagging

func (b *InMemoryBackend) PutObjectTagging(
	_ context.Context,
	input *s3.PutObjectTaggingInput,
) (*s3.PutObjectTaggingOutput, error)

func (*InMemoryBackend) PutPublicAccessBlock

func (b *InMemoryBackend) PutPublicAccessBlock(
	_ context.Context,
	bucketName, configXML string,
) error

PutPublicAccessBlock stores the public access block configuration for a bucket.

func (*InMemoryBackend) Regions

func (b *InMemoryBackend) Regions() []string

Regions returns all distinct regions that contain at least one active bucket.

func (*InMemoryBackend) RenameObject

func (b *InMemoryBackend) RenameObject(
	_ context.Context,
	bucketName, sourceKey, targetKey string,
) error

RenameObject performs an atomic copy+delete of the source key into a new key. The target key is taken from `targetKey` (relative to the same bucket).

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all in-memory state from the backend. It is used by the POST /_gopherstack/reset endpoint for CI pipelines and rapid local development.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads backend state from a JSON snapshot. It implements persistence.Persistable.

func (*InMemoryBackend) RestoreObject

func (b *InMemoryBackend) RestoreObject(_ context.Context, bucketName, key string, days int) error

RestoreObject marks the latest object version as restored for the given duration. AWS returns 202 Accepted and asynchronously restores; we mark the restore as completed immediately and set an expiry, since this is an in-memory mock.

func (*InMemoryBackend) SetDefaultRegion

func (b *InMemoryBackend) SetDefaultRegion(region string)

SetDefaultRegion sets the default region for this backend.

func (*InMemoryBackend) SetServiceContext

func (b *InMemoryBackend) SetServiceContext(ctx context.Context)

SetServiceContext wires the long-lived service context used to parent background work (replication). Called from the handler's StartWorker. Cancels the previous default background context before switching to the service-provided one.

func (*InMemoryBackend) Shutdown

func (b *InMemoryBackend) Shutdown()

Shutdown cancels the backend's service context and waits for all in-flight replication goroutines to complete. Safe to call more than once.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the backend state to JSON. It implements persistence.Persistable.

func (*InMemoryBackend) UpdateBucketMetadataInventoryTableConfig

func (b *InMemoryBackend) UpdateBucketMetadataInventoryTableConfig(
	_ context.Context,
	bucketName, configXML string,
) error

UpdateBucketMetadataInventoryTableConfig stores the metadata inventory table configuration XML for an S3 Tables bucket.

func (*InMemoryBackend) UpdateBucketMetadataJournalTableConfig

func (b *InMemoryBackend) UpdateBucketMetadataJournalTableConfig(
	_ context.Context,
	bucketName, configXML string,
) error

UpdateBucketMetadataJournalTableConfig stores the metadata journal table configuration XML for an S3 Tables bucket.

func (*InMemoryBackend) UpdateObjectEncryption

func (b *InMemoryBackend) UpdateObjectEncryption(
	_ context.Context,
	bucketName, key, algorithm, kmsKeyID string,
) error

UpdateObjectEncryption updates the SSE algorithm (and optional KMS key id) of the latest version of the named object.

func (*InMemoryBackend) UploadPart

func (b *InMemoryBackend) UploadPart(
	ctx context.Context,
	input *s3.UploadPartInput,
) (*s3.UploadPartOutput, error)

func (*InMemoryBackend) WithCompressionMinBytes

func (b *InMemoryBackend) WithCompressionMinBytes(n int) *InMemoryBackend

WithCompressionMinBytes sets the minimum object size (in bytes) below which gzip compression is skipped. A value of 0 compresses all objects regardless of size (the original behaviour). Negative values are clamped to 0 to prevent misconfiguration (e.g., via env/flags) from silently changing semantics.

func (*InMemoryBackend) WithSkipMultipartSizeCheck

func (b *InMemoryBackend) WithSkipMultipartSizeCheck() *InMemoryBackend

WithSkipMultipartSizeCheck disables the 5 MiB minimum non-last-part size enforcement in CompleteMultipartUpload. Use only in tests.

type InitiateMultipartUploadResult

type InitiateMultipartUploadResult struct {
	XMLName  xml.Name `xml:"InitiateMultipartUploadResult"`
	Bucket   string   `xml:"Bucket"`
	Key      string   `xml:"Key"`
	UploadID string   `xml:"UploadId"`
}

type InvalidRangeError

type InvalidRangeError struct {
	XMLName        xml.Name `xml:"Error"`
	Code           string   `xml:"Code"`
	Message        string   `xml:"Message"`
	Resource       string   `xml:"Resource"`
	RequestID      string   `xml:"RequestId"`
	RangeRequested string   `xml:"RangeRequested"`
	// ActualObjectSize is last so its 8-byte int sits after the pointer-bearing
	// string fields, keeping the GC pointer-scan region contiguous.
	ActualObjectSize int64 `xml:"ActualObjectSize"`
}

InvalidRangeError is the XML body S3 returns with a 416 response when a Range request is syntactically valid but cannot be satisfied (the first byte position is at or beyond the object size). It mirrors the real AWS payload, which carries the actual object size and the rejected range so clients can recover without an extra HeadObject round-trip.

type Janitor

type Janitor struct {
	Backend *InMemoryBackend

	Interval    time.Duration
	TaskTimeout time.Duration
	// contains filtered or unexported fields
}

Janitor is the S3 background worker that drains buckets queued for async deletion and records queue-depth metrics for the live dashboard.

func NewJanitor

func NewJanitor(backend *InMemoryBackend, settings Settings) *Janitor

NewJanitor creates a new S3 Janitor for the given backend. The janitor interval is taken from the provided settings; if zero, it falls back to defaultJanitorInterval.

func (*Janitor) GetExpirationHeader

func (j *Janitor) GetExpirationHeader(
	lcXML string,
	key string,
	tags []types.Tag,
	lastModified time.Time,
) string

GetExpirationHeader calculates the x-amz-expiration header for an object based on the bucket's lifecycle configuration.

func (*Janitor) Run

func (j *Janitor) Run(ctx context.Context)

Run runs the janitor loop until ctx is cancelled. Each tick, sweepAndDrain spawns one goroutine per pending bucket so that thousands of large buckets are drained in parallel rather than serially.

The worker primitive recovers panics from each sweep automatically.

func (*Janitor) SweepOnce

func (j *Janitor) SweepOnce(ctx context.Context)

SweepOnce runs a single sweep pass (lifecycle + multipart cleanup). Exposed for testing. Note: sweepAndDrain is intentionally excluded here because it spawns long-lived drain goroutines that must outlive any per-task timeout context.

type LambdaInvoker

type LambdaInvoker interface {
	InvokeFunction(
		ctx context.Context,
		name, invocationType string,
		payload []byte,
	) ([]byte, int, error)
}

LambdaInvoker invokes a Lambda function by name or ARN with a JSON payload.

type ListAllMyBucketsResult

type ListAllMyBucketsResult struct {
	XMLName xml.Name    `xml:"ListAllMyBucketsResult"`
	Owner   *Owner      `xml:"Owner"`
	Buckets []BucketXML `xml:"Buckets>Bucket"`
}

type ListBucketResult

type ListBucketResult struct {
	XMLName        xml.Name          `xml:"ListBucketResult"`
	Name           string            `xml:"Name"`
	Prefix         string            `xml:"Prefix"`
	Delimiter      string            `xml:"Delimiter,omitempty"`
	Marker         string            `xml:"Marker,omitempty"`
	NextMarker     string            `xml:"NextMarker,omitempty"`
	EncodingType   string            `xml:"EncodingType,omitempty"`
	Contents       []ObjectXML       `xml:"Contents"`
	CommonPrefixes []CommonPrefixXML `xml:"CommonPrefixes,omitempty"`
	MaxKeys        int               `xml:"MaxKeys"`
	IsTruncated    bool              `xml:"IsTruncated"`
}

type ListBucketV2Result

type ListBucketV2Result struct {
	XMLName               xml.Name          `xml:"ListBucketResult"`
	StartAfter            string            `xml:"StartAfter,omitempty"`
	Prefix                string            `xml:"Prefix"`
	Delimiter             string            `xml:"Delimiter,omitempty"`
	ContinuationToken     string            `xml:"ContinuationToken,omitempty"`
	NextContinuationToken string            `xml:"NextContinuationToken,omitempty"`
	Name                  string            `xml:"Name"`
	EncodingType          string            `xml:"EncodingType,omitempty"`
	Contents              []ObjectXML       `xml:"Contents"`
	CommonPrefixes        []CommonPrefixXML `xml:"CommonPrefixes,omitempty"`
	KeyCount              int               `xml:"KeyCount"`
	MaxKeys               int               `xml:"MaxKeys"`
	IsTruncated           bool              `xml:"IsTruncated"`
}

ListBucketV2Result is the XML response for ListObjectsV2.

type ListMultipartUploadsResult

type ListMultipartUploadsResult struct {
	XMLName            xml.Name          `xml:"ListMultipartUploadsResult"`
	Xmlns              string            `xml:"xmlns,attr,omitempty"`
	Bucket             string            `xml:"Bucket"`
	Delimiter          string            `xml:"Delimiter,omitempty"`
	Prefix             string            `xml:"Prefix"`
	KeyMarker          string            `xml:"KeyMarker,omitempty"`
	UploadIDMarker     string            `xml:"UploadIdMarker,omitempty"`
	NextKeyMarker      string            `xml:"NextKeyMarker,omitempty"`
	NextUploadIDMarker string            `xml:"NextUploadIdMarker,omitempty"`
	EncodingType       string            `xml:"EncodingType,omitempty"`
	Uploads            []MultipartUpload `xml:"Upload"`
	CommonPrefixes     []CommonPrefixXML `xml:"CommonPrefixes,omitempty"`
	MaxUploads         int               `xml:"MaxUploads"`
	IsTruncated        bool              `xml:"IsTruncated"`
}

type ListPartsResult

type ListPartsResult struct {
	XMLName              xml.Name  `xml:"ListPartsResult"`
	Xmlns                string    `xml:"xmlns,attr,omitempty"`
	Bucket               string    `xml:"Bucket"`
	Key                  string    `xml:"Key"`
	UploadID             string    `xml:"UploadId"`
	NextPartNumberMarker string    `xml:"NextPartNumberMarker,omitempty"`
	Parts                []PartXML `xml:"Part"`
	PartNumberMarker     int       `xml:"PartNumberMarker"`
	MaxParts             int       `xml:"MaxParts"`
	IsTruncated          bool      `xml:"IsTruncated"`
}

type ListVersionsResult

type ListVersionsResult struct {
	XMLName             xml.Name           `xml:"ListVersionsResult"`
	Name                string             `xml:"Name"`
	Prefix              string             `xml:"Prefix"`
	KeyMarker           string             `xml:"KeyMarker"`
	VersionIDMarker     string             `xml:"VersionIdMarker"`
	NextKeyMarker       string             `xml:"NextKeyMarker,omitempty"`
	NextVersionIDMarker string             `xml:"NextVersionIdMarker,omitempty"`
	Delimiter           string             `xml:"Delimiter,omitempty"`
	EncodingType        string             `xml:"EncodingType,omitempty"`
	CommonPrefixes      []CommonPrefixXML  `xml:"CommonPrefixes"`
	Versions            []ObjectVersionXML `xml:"Version"`
	DeleteMarkers       []DeleteMarkerXML  `xml:"DeleteMarker"`
	MaxKeys             int                `xml:"MaxKeys"`
	IsTruncated         bool               `xml:"IsTruncated"`
}

type LocationConstraintResponse

type LocationConstraintResponse struct {
	XMLName xml.Name `xml:"LocationConstraint"`
	Xmlns   string   `xml:"xmlns,attr"`
	Region  string   `xml:",chardata"`
}

LocationConstraintResponse is the XML response body for GetBucketLocation.

type LoggingEnabled

type LoggingEnabled struct {
	TargetBucket string `xml:"TargetBucket"`
	TargetPrefix string `xml:"TargetPrefix"`
}

LoggingEnabled holds the logging target configuration for a bucket.

type MultipartUpload

type MultipartUpload struct {
	Initiated time.Time `xml:"Initiated"`
	Key       string    `xml:"Key"`
	UploadID  string    `xml:"UploadId"`
}

MultipartUpload describes a single in-progress multipart upload.

type NotificationDispatcher

type NotificationDispatcher interface {
	// DispatchObjectCreated sends an s3:ObjectCreated:Put notification for a PutObject operation.
	DispatchObjectCreated(
		ctx context.Context,
		bucket, key, etag string,
		size int64,
		notifXML string,
	)
	// DispatchObjectCopied sends an s3:ObjectCreated:Copy notification for a CopyObject operation.
	DispatchObjectCopied(ctx context.Context, bucket, key, etag string, size int64, notifXML string)
	// DispatchObjectCompleted sends an s3:ObjectCreated:CompleteMultipartUpload notification.
	DispatchObjectCompleted(
		ctx context.Context,
		bucket, key, etag string,
		size int64,
		notifXML string,
	)
	// DispatchObjectDeleted sends an s3:ObjectRemoved notification for the given object.
	DispatchObjectDeleted(ctx context.Context, bucket, key, notifXML string)
	// DispatchObjectRestorePost sends an s3:ObjectRestore:Post notification for a
	// RestoreObject request (object restore initiation).
	DispatchObjectRestorePost(ctx context.Context, bucket, key, notifXML string)
}

NotificationDispatcher delivers S3 event notifications to configured targets.

func NewNotificationDispatcher

func NewNotificationDispatcher(targets *NotificationTargets, region string) NotificationDispatcher

NewNotificationDispatcher creates a NotificationDispatcher that delivers events to the provided in-process targets (SQS, SNS, Lambda).

type NotificationTargets

type NotificationTargets struct {
	SQSSender            SQSSender
	SNSPublisher         SNSPublisher
	LambdaInvoker        LambdaInvoker
	EventBridgePublisher EventBridgePublisher
}

NotificationTargets holds concrete delivery clients for each supported target type.

type ObjectAttributes

type ObjectAttributes struct {
	LastModified time.Time
	Checksum     map[string]string
	ETag         string
	StorageClass string
	ObjectSize   int64
}

ObjectAttributes is the projection of object metadata returned by GetObjectAttributes.

type ObjectLegalHold

type ObjectLegalHold struct {
	XMLName xml.Name `xml:"LegalHold"`
	Xmlns   string   `xml:"xmlns,attr,omitempty"`
	Status  string   `xml:"Status"`
}

ObjectLegalHold is the XML body for PutObjectLegalHold / GetObjectLegalHold.

type ObjectLockConfiguration

type ObjectLockConfiguration struct {
	Rule              *ObjectLockRule `xml:"Rule,omitempty"`
	XMLName           xml.Name        `xml:"ObjectLockConfiguration"`
	Xmlns             string          `xml:"xmlns,attr,omitempty"`
	ObjectLockEnabled string          `xml:"ObjectLockEnabled"`
}

ObjectLockConfiguration is the XML body for PutObjectLockConfiguration / GetObjectLockConfiguration.

type ObjectLockRule

type ObjectLockRule struct {
	DefaultRetention *DefaultRetention `xml:"DefaultRetention,omitempty"`
}

ObjectLockRule holds the default retention rule for a bucket.

type ObjectMetadata

type ObjectMetadata struct {
	Tags              *tags.Tags
	UserMetadata      map[string]string
	ContentType       string
	ChecksumAlgorithm string
	ChecksumValue     string
}

ObjectMetadata holds internal metadata for storage operations. (Keeping this compatibility type if needed, though mostly replaced by SDK types usage).

type ObjectRetention

type ObjectRetention struct {
	XMLName         xml.Name `xml:"Retention"`
	Xmlns           string   `xml:"xmlns,attr,omitempty"`
	Mode            string   `xml:"Mode"`
	RetainUntilDate string   `xml:"RetainUntilDate"`
}

ObjectRetention is the XML body for PutObjectRetention / GetObjectRetention.

type ObjectVersionXML

type ObjectVersionXML struct {
	Owner        *Owner `xml:"Owner"`
	Key          string `xml:"Key"`
	VersionID    string `xml:"VersionId"`
	LastModified string `xml:"LastModified"`
	ETag         string `xml:"ETag"`
	StorageClass string `xml:"StorageClass"`
	Size         int64  `xml:"Size"`
	IsLatest     bool   `xml:"IsLatest"`
}

type ObjectXML

type ObjectXML struct {
	Key               string `xml:"Key"`
	LastModified      string `xml:"LastModified"`
	ETag              string `xml:"ETag"`
	StorageClass      string `xml:"StorageClass"`
	ChecksumAlgorithm string `xml:"ChecksumAlgorithm,omitempty"`
	Size              int64  `xml:"Size"`
}

type Owner

type Owner struct {
	ID          string `xml:"ID"`
	DisplayName string `xml:"DisplayName"`
}

type OwnershipControls

type OwnershipControls struct {
	XMLName xml.Name                `xml:"OwnershipControls"`
	Xmlns   string                  `xml:"xmlns,attr,omitempty"`
	Rules   []OwnershipControlsRule `xml:"Rule"`
}

OwnershipControls is the XML body for PutBucketOwnershipControls / GetBucketOwnershipControls.

type OwnershipControlsRule

type OwnershipControlsRule struct {
	ObjectOwnership string `xml:"ObjectOwnership"`
}

OwnershipControlsRule represents a single ownership controls rule.

type PartXML

type PartXML struct {
	ETag       string `xml:"ETag"`
	Size       int64  `xml:"Size"`
	PartNumber int    `xml:"PartNumber"`
}

PartXML describes a single uploaded part in a multipart upload.

type Provider

type Provider struct{}

Provider implements service.Provider for the S3 service.

func (*Provider) Init

Init initializes the S3 service backend, compressor, janitor, and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the logical name of the provider.

type PublicAccessBlockConfiguration

type PublicAccessBlockConfiguration struct {
	XMLName               xml.Name `xml:"PublicAccessBlockConfiguration"`
	Xmlns                 string   `xml:"xmlns,attr,omitempty"`
	BlockPublicAcls       bool     `xml:"BlockPublicAcls"`
	IgnorePublicAcls      bool     `xml:"IgnorePublicAcls"`
	BlockPublicPolicy     bool     `xml:"BlockPublicPolicy"`
	RestrictPublicBuckets bool     `xml:"RestrictPublicBuckets"`
}

PublicAccessBlockConfiguration is the XML body for PutPublicAccessBlock / GetPublicAccessBlock.

type ReplicationConfiguration

type ReplicationConfiguration struct {
	XMLName xml.Name          `xml:"ReplicationConfiguration"`
	Xmlns   string            `xml:"xmlns,attr,omitempty"`
	Role    string            `xml:"Role"`
	Rules   []ReplicationRule `xml:"Rule"`
}

ReplicationConfiguration is the XML body for PutBucketReplication / GetBucketReplication. The full structure is complex; we store and return the raw XML for fidelity.

type ReplicationDestination

type ReplicationDestination struct {
	Bucket       string `xml:"Bucket"`
	StorageClass string `xml:"StorageClass,omitempty"`
}

ReplicationDestination specifies the destination bucket for replication.

type ReplicationRule

type ReplicationRule struct {
	Destination             ReplicationDestination  `xml:"Destination"`
	DeleteMarkerReplication DeleteMarkerReplication `xml:"DeleteMarkerReplication"`
	ID                      string                  `xml:"ID,omitempty"`
	Prefix                  string                  `xml:"Prefix,omitempty"`
	Status                  string                  `xml:"Status"`
}

ReplicationRule is a single replication rule within a ReplicationConfiguration.

type S3Handler

type S3Handler struct {
	Backend StorageBackend

	DefaultRegion string
	Endpoint      string
	// PresignSecret, when non-empty, opts the handler into cryptographic
	// verification of presigned-URL signatures (SigV4 query-auth). It is empty
	// by default so presigned URLs are accepted on structure/expiry alone,
	// preserving backwards-compatible behaviour.
	PresignSecret string
	// contains filtered or unexported fields
}

S3Handler implements the S3-compatible service for object storage operations.

func NewHandler

func NewHandler(backend StorageBackend) *S3Handler

NewHandler creates a new S3 Handler with the given backend.

func (*S3Handler) BucketsByRegion

func (h *S3Handler) BucketsByRegion(region string) []types.Bucket

BucketsByRegion returns buckets in the given region (all if empty). Returns an empty slice when not using the in-memory backend.

func (*S3Handler) ChaosOperations

func (h *S3Handler) ChaosOperations() []string

ChaosOperations returns all operations that can be fault-injected.

func (*S3Handler) ChaosRegions

func (h *S3Handler) ChaosRegions() []string

ChaosRegions returns all regions this S3 instance handles.

func (*S3Handler) ChaosServiceName

func (h *S3Handler) ChaosServiceName() string

ChaosServiceName returns the lowercase AWS service name for fault rule matching.

func (*S3Handler) ExtractOperation

func (h *S3Handler) ExtractOperation(c *echo.Context) string

ExtractOperation returns the current S3 operation from context.

func (*S3Handler) ExtractResource

func (h *S3Handler) ExtractResource(c *echo.Context) string

ExtractResource returns the bucket name for this request.

func (*S3Handler) GetSupportedOperations

func (h *S3Handler) GetSupportedOperations() []string

GetSupportedOperations returns a list of supported S3 operations.

func (*S3Handler) Handler

func (h *S3Handler) Handler() echo.HandlerFunc

Handler returns the Echo handler function for S3 requests.

func (*S3Handler) MatchPriority

func (h *S3Handler) MatchPriority() int

MatchPriority returns the priority for the S3 matcher. Catch-all matchers have the lowest priority (0), ensuring other services match first.

func (*S3Handler) Name

func (h *S3Handler) Name() string

Name returns the service identifier.

func (*S3Handler) Purge

func (h *S3Handler) Purge(ctx context.Context, cutoff time.Time)

Purge removes resources created before the given cutoff time.

func (*S3Handler) Regions

func (h *S3Handler) Regions() []string

Regions returns all regions with buckets in the backend. Returns an empty slice when not using the in-memory backend.

func (*S3Handler) Reset

func (h *S3Handler) Reset()

Reset clears all in-memory state from the backend. It is used by the POST /_gopherstack/reset endpoint for CI pipelines and rapid local development.

func (*S3Handler) Restore

func (h *S3Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*S3Handler) RouteMatcher

func (h *S3Handler) RouteMatcher() service.Matcher

RouteMatcher returns a matcher that accepts all S3 requests (catch-all). With priority-based routing, S3 is matched last due to low priority. Excludes API endpoints and dashboard routes which take precedence.

func (*S3Handler) ServeWebsite

func (h *S3Handler) ServeWebsite(c *echo.Context) error

ServeWebsite serves a static file from an S3 bucket configured for website hosting. It is invoked by the GET /_gopherstack/website/{bucket}/{key+} route registered in cli.go. The bucket must have a website configuration stored via PutBucketWebsite.

func (*S3Handler) SetNotificationDispatcher

func (h *S3Handler) SetNotificationDispatcher(d NotificationDispatcher)

SetNotificationDispatcher attaches a NotificationDispatcher that delivers S3 event notifications to SQS/SNS/Lambda targets on PutObject and DeleteObject.

func (*S3Handler) SetObjectLambdaConfig

func (h *S3Handler) SetObjectLambdaConfig(bucket, lambdaARN string)

SetObjectLambdaConfig registers a Lambda ARN to be invoked for GetObject requests on the given bucket. When set, GetObject triggers the Lambda and waits for WriteGetObjectResponse before streaming the (transformed) body back to the caller.

func (*S3Handler) Snapshot

func (h *S3Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

func (*S3Handler) StartWorker

func (h *S3Handler) StartWorker(ctx context.Context) error

StartWorker starts the background janitor if it is configured.

func (*S3Handler) WithJanitor

func (h *S3Handler) WithJanitor(settings Settings, taskTimeout ...time.Duration) *S3Handler

WithJanitor attaches a background janitor to the handler.

func (*S3Handler) WithPresignValidation

func (h *S3Handler) WithPresignValidation(secret string) *S3Handler

WithPresignValidation enables cryptographic SigV4 verification of presigned-URL signatures, checking each signature against the given secret. A blank secret defaults to "test" (the conventional dummy credential). When never called, presigned URLs are validated on structure and expiry only.

type SNSPublisher

type SNSPublisher interface {
	PublishToTopic(ctx context.Context, topicARN, message, subject string) error
}

SNSPublisher publishes a message to an SNS topic identified by ARN.

type SQSSender

type SQSSender interface {
	SendMessageToQueue(ctx context.Context, queueARN, messageBody string) error
}

SQSSender sends a message body to an SQS queue identified by ARN.

type ServerSideEncryptionByDefault

type ServerSideEncryptionByDefault struct {
	SSEAlgorithm   string `xml:"SSEAlgorithm"`
	KMSMasterKeyID string `xml:"KMSMasterKeyID,omitempty"`
}

ServerSideEncryptionByDefault holds the default encryption algorithm and optional KMS key.

type ServerSideEncryptionConfiguration

type ServerSideEncryptionConfiguration struct {
	XMLName xml.Name                   `xml:"ServerSideEncryptionConfiguration"`
	Xmlns   string                     `xml:"xmlns,attr,omitempty"`
	Rules   []ServerSideEncryptionRule `xml:"Rule"`
}

ServerSideEncryptionConfiguration is the XML body for PutBucketEncryption / GetBucketEncryption.

type ServerSideEncryptionRule

type ServerSideEncryptionRule struct {
	ApplyServerSideEncryptionByDefault ServerSideEncryptionByDefault `xml:"ApplyServerSideEncryptionByDefault"`
	BucketKeyEnabled                   bool                          `xml:"BucketKeyEnabled,omitempty"`
}

ServerSideEncryptionRule represents a single encryption rule.

type Settings

type Settings struct {
	DefaultRegion       string        `json:"default_region"        env:"S3_REGION"                default:"us-east-1" help:"Default region for S3."` //nolint:lll // Kong struct tag makes this line long
	JanitorInterval     time.Duration `json:"janitor_interval"      env:"S3_JANITOR_INTERVAL"      default:"500ms"     help:"Janitor tick interval."` //nolint:lll // Kong struct tag makes this line long
	CompressionMinBytes int           ``                                                                                                              //nolint:lll // config struct tags are intentionally verbose
	/* 219-byte string literal not displayed */
}

Settings holds service-level configuration for the S3 backend. Fields are picked up by the Kong CLI parser when this struct is embedded in the root CLI command.

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings returns a Settings struct populated with the documented defaults. This is used when no ConfigProvider is available at init time.

type StorageBackend

type StorageBackend interface {
	CreateBucket(ctx context.Context, input *s3.CreateBucketInput) (*s3.CreateBucketOutput, error)
	DeleteBucket(ctx context.Context, input *s3.DeleteBucketInput) (*s3.DeleteBucketOutput, error)
	HeadBucket(ctx context.Context, input *s3.HeadBucketInput) (*s3.HeadBucketOutput, error)
	ListBuckets(ctx context.Context, input *s3.ListBucketsInput) (*s3.ListBucketsOutput, error)

	PutObject(ctx context.Context, input *s3.PutObjectInput) (*s3.PutObjectOutput, error)
	GetObject(ctx context.Context, input *s3.GetObjectInput) (*s3.GetObjectOutput, error)
	HeadObject(ctx context.Context, input *s3.HeadObjectInput) (*s3.HeadObjectOutput, error)
	DeleteObject(ctx context.Context, input *s3.DeleteObjectInput) (*s3.DeleteObjectOutput, error)
	DeleteObjects(
		ctx context.Context,
		input *s3.DeleteObjectsInput,
	) (*s3.DeleteObjectsOutput, error)
	ListObjects(ctx context.Context, input *s3.ListObjectsInput) (*s3.ListObjectsOutput, error)
	ListObjectsV2(
		ctx context.Context,
		input *s3.ListObjectsV2Input,
	) (*s3.ListObjectsV2Output, error)
	ListObjectVersions(
		ctx context.Context,
		input *s3.ListObjectVersionsInput,
	) (*s3.ListObjectVersionsOutput, error)

	// Versioning
	PutBucketVersioning(
		ctx context.Context,
		input *s3.PutBucketVersioningInput,
	) (*s3.PutBucketVersioningOutput, error)
	GetBucketVersioning(
		ctx context.Context,
		input *s3.GetBucketVersioningInput,
	) (*s3.GetBucketVersioningOutput, error)

	// Tagging
	PutObjectTagging(
		ctx context.Context,
		input *s3.PutObjectTaggingInput,
	) (*s3.PutObjectTaggingOutput, error)
	GetObjectTagging(
		ctx context.Context,
		input *s3.GetObjectTaggingInput,
	) (*s3.GetObjectTaggingOutput, error)
	DeleteObjectTagging(
		ctx context.Context,
		input *s3.DeleteObjectTaggingInput,
	) (*s3.DeleteObjectTaggingOutput, error)

	// Bucket Tagging
	PutBucketTagging(ctx context.Context, bucket string, tags []types.Tag) error
	GetBucketTagging(ctx context.Context, bucket string) ([]types.Tag, error)
	DeleteBucketTagging(ctx context.Context, bucket string) error

	// ACL
	PutBucketACL(ctx context.Context, bucket, acl string) error
	GetBucketACL(ctx context.Context, bucket string) (string, error)

	// Policy
	PutBucketPolicy(ctx context.Context, bucket, policy string) error
	GetBucketPolicy(ctx context.Context, bucket string) (string, error)
	DeleteBucketPolicy(ctx context.Context, bucket string) error

	// CORS
	PutBucketCORS(ctx context.Context, bucket, corsXML string) error
	GetBucketCORS(ctx context.Context, bucket string) (string, error)
	DeleteBucketCORS(ctx context.Context, bucket string) error

	// Lifecycle
	PutBucketLifecycleConfiguration(ctx context.Context, bucket, lifecycleXML string) error
	GetBucketLifecycleConfiguration(ctx context.Context, bucket string) (string, error)
	DeleteBucketLifecycleConfiguration(ctx context.Context, bucket string) error

	// Website
	PutBucketWebsite(ctx context.Context, bucket, websiteXML string) error
	GetBucketWebsite(ctx context.Context, bucket string) (string, error)
	DeleteBucketWebsite(ctx context.Context, bucket string) error

	// Encryption
	PutBucketEncryption(ctx context.Context, bucket, encryptionXML string) error
	GetBucketEncryption(ctx context.Context, bucket string) (string, error)
	DeleteBucketEncryption(ctx context.Context, bucket string) error

	// Public Access Block
	PutPublicAccessBlock(ctx context.Context, bucket, configXML string) error
	GetPublicAccessBlock(ctx context.Context, bucket string) (string, error)
	DeletePublicAccessBlock(ctx context.Context, bucket string) error

	// Ownership Controls
	PutBucketOwnershipControls(ctx context.Context, bucket, configXML string) error
	GetBucketOwnershipControls(ctx context.Context, bucket string) (string, error)
	DeleteBucketOwnershipControls(ctx context.Context, bucket string) error

	// Logging
	PutBucketLogging(ctx context.Context, bucket, loggingXML string) error
	GetBucketLogging(ctx context.Context, bucket string) (string, error)

	// Replication
	PutBucketReplication(ctx context.Context, bucket, replicationXML string) error
	GetBucketReplication(ctx context.Context, bucket string) (string, error)
	DeleteBucketReplication(ctx context.Context, bucket string) error

	// Notifications
	PutBucketNotificationConfiguration(ctx context.Context, bucket, notifXML string) error
	GetBucketNotificationConfiguration(ctx context.Context, bucket string) (string, error)

	// Object Lock
	PutObjectLockConfiguration(ctx context.Context, bucket, configXML string) error
	GetObjectLockConfiguration(ctx context.Context, bucket string) (string, error)
	PutObjectRetention(
		ctx context.Context,
		bucket, key string,
		versionID *string,
		mode string,
		retainUntil time.Time,
	) error
	GetObjectRetention(
		ctx context.Context,
		bucket, key string,
		versionID *string,
	) (mode string, retainUntil time.Time, err error)
	PutObjectLegalHold(
		ctx context.Context,
		bucket, key string,
		versionID *string,
		status string,
	) error
	GetObjectLegalHold(
		ctx context.Context,
		bucket, key string,
		versionID *string,
	) (status string, err error)

	// Multipart
	CreateMultipartUpload(
		ctx context.Context,
		input *s3.CreateMultipartUploadInput,
	) (*s3.CreateMultipartUploadOutput, error)
	UploadPart(ctx context.Context, input *s3.UploadPartInput) (*s3.UploadPartOutput, error)
	CompleteMultipartUpload(
		ctx context.Context,
		input *s3.CompleteMultipartUploadInput,
	) (*s3.CompleteMultipartUploadOutput, error)
	AbortMultipartUpload(
		ctx context.Context,
		input *s3.AbortMultipartUploadInput,
	) (*s3.AbortMultipartUploadOutput, error)
	ListMultipartUploads(
		ctx context.Context,
		input *s3.ListMultipartUploadsInput,
	) (*s3.ListMultipartUploadsOutput, error)
	ListParts(
		ctx context.Context,
		input *s3.ListPartsInput,
	) (*s3.ListPartsOutput, error)

	// Metadata helpers
	GetBucketMetadata(
		ctx context.Context,
		bucketName string,
	) (region string, lifecycleXML string, tags []types.Tag, err error)

	// Analytics (supports multiple configs per bucket via id)
	PutBucketAnalyticsConfiguration(ctx context.Context, bucket, id, configXML string) error
	GetBucketAnalyticsConfiguration(ctx context.Context, bucket, id string) (string, error)
	DeleteBucketAnalyticsConfiguration(ctx context.Context, bucket, id string) error
	ListBucketAnalyticsConfigurations(ctx context.Context, bucket string) ([]string, error)

	// Intelligent Tiering (supports multiple configs per bucket via id)
	PutBucketIntelligentTieringConfiguration(
		ctx context.Context,
		bucket, id, configXML string,
	) error
	GetBucketIntelligentTieringConfiguration(ctx context.Context, bucket, id string) (string, error)
	DeleteBucketIntelligentTieringConfiguration(ctx context.Context, bucket, id string) error
	ListBucketIntelligentTieringConfigurations(ctx context.Context, bucket string) ([]string, error)

	// Inventory (supports multiple configs per bucket via id)
	PutBucketInventoryConfiguration(ctx context.Context, bucket, id, configXML string) error
	GetBucketInventoryConfiguration(ctx context.Context, bucket, id string) (string, error)
	DeleteBucketInventoryConfiguration(ctx context.Context, bucket, id string) error
	ListBucketInventoryConfigurations(ctx context.Context, bucket string) ([]string, error)

	// Lifecycle (legacy alias)
	DeleteBucketLifecycle(ctx context.Context, bucket string) error

	// Metadata Configuration
	CreateBucketMetadataConfiguration(ctx context.Context, bucket, configXML string) error
	GetBucketMetadataConfiguration(ctx context.Context, bucket string) (string, error)
	DeleteBucketMetadataConfiguration(ctx context.Context, bucket string) error

	// Metadata Table Configuration
	CreateBucketMetadataTableConfiguration(ctx context.Context, bucket, configXML string) error
	GetBucketMetadataTableConfiguration(ctx context.Context, bucket string) (string, error)
	DeleteBucketMetadataTableConfiguration(ctx context.Context, bucket string) error

	// Metrics (supports multiple configs per bucket via id)
	PutBucketMetricsConfiguration(ctx context.Context, bucket, id, configXML string) error
	GetBucketMetricsConfiguration(ctx context.Context, bucket, id string) (string, error)
	DeleteBucketMetricsConfiguration(ctx context.Context, bucket, id string) error
	ListBucketMetricsConfigurations(ctx context.Context, bucket string) ([]string, error)

	// Session
	CreateSession(ctx context.Context, bucket string) (string, error)

	// Accelerate / RequestPayment configurations
	PutBucketAccelerateConfiguration(ctx context.Context, bucket, status string) error
	GetBucketAccelerateConfiguration(ctx context.Context, bucket string) (string, error)
	PutBucketRequestPayment(ctx context.Context, bucket, payer string) error
	GetBucketRequestPayment(ctx context.Context, bucket string) (string, error)

	// ABAC Configuration (S3 Tables / Express)
	PutBucketAbac(ctx context.Context, bucket, configXML string) error
	GetBucketAbac(ctx context.Context, bucket string) (string, error)

	// S3 Express directory buckets
	ListDirectoryBuckets(ctx context.Context) ([]types.Bucket, error)

	// Metadata Inventory / Journal Table Configurations (S3 Tables)
	UpdateBucketMetadataInventoryTableConfig(ctx context.Context, bucket, configXML string) error
	UpdateBucketMetadataJournalTableConfig(ctx context.Context, bucket, configXML string) error

	// GetObjectAttributes / RestoreObject / RenameObject
	GetObjectAttributes(
		ctx context.Context,
		bucket, key, versionID string,
	) (*ObjectAttributes, error)
	RestoreObject(ctx context.Context, bucket, key string, days int) error
	RenameObject(ctx context.Context, bucket, sourceKey, targetKey string) error

	// Object ACLs
	PutObjectACL(ctx context.Context, bucket, key, versionID, acl string) error
	GetObjectACL(ctx context.Context, bucket, key, versionID string) (string, error)

	// Per-object SSE updates
	UpdateObjectEncryption(ctx context.Context, bucket, key, algorithm, kmsKeyID string) error
}

type StorageClassTransition

type StorageClassTransition struct {
	TransitionedAt time.Time `json:"transitionedAt"`
	FromClass      string    `json:"fromClass"`
	ToClass        string    `json:"toClass"`
	RuleID         string    `json:"ruleID,omitempty"`
}

StorageClassTransition records a single storage class change applied by a lifecycle rule.

type StoredBucket

type StoredBucket struct {
	CreationDate time.Time                `json:"creationDate"`
	Objects      map[string]*StoredObject `json:"objects,omitempty"`

	Region                       string                       `json:"region,omitempty"`
	WebsiteConfig                string                       `json:"websiteConfig,omitempty"`
	PublicAccessBlockConfig      string                       `json:"publicAccessBlockConfig,omitempty"`
	LifecycleConfig              string                       `json:"lifecycleConfig,omitempty"`
	NotificationConfig           string                       `json:"notificationConfig,omitempty"`
	ObjectLockConfig             string                       `json:"objectLockConfig,omitempty"`
	Policy                       string                       `json:"policy,omitempty"`
	EncryptionConfig             string                       `json:"encryptionConfig,omitempty"`
	CORSConfig                   string                       `json:"corsConfig,omitempty"`
	OwnershipControlsConfig      string                       `json:"ownershipControlsConfig,omitempty"`
	LoggingConfig                string                       `json:"loggingConfig,omitempty"`
	ReplicationConfig            string                       `json:"replicationConfig,omitempty"`
	AnalyticsConfigs             map[string]string            `json:"analyticsConfigs,omitempty"`
	IntelligentTieringConfigs    map[string]string            `json:"intelligentTieringConfigs,omitempty"`
	InventoryConfigs             map[string]string            `json:"inventoryConfigs,omitempty"`
	MetadataConfig               string                       `json:"metadataConfig,omitempty"`
	MetadataTableConfig          string                       `json:"metadataTableConfig,omitempty"`
	AbacConfig                   string                       `json:"abacConfig,omitempty"`
	MetadataInventoryTableConfig string                       `json:"metadataInventoryTableConfig,omitempty"`
	MetadataJournalTableConfig   string                       `json:"metadataJournalTableConfig,omitempty"`
	MetricsConfigs               map[string]string            `json:"metricsConfigs,omitempty"`
	Versioning                   types.BucketVersioningStatus `json:"versioning,omitempty"`
	Name                         string                       `json:"name"`
	ACL                          string                       `json:"acl,omitempty"`
	AccelerateStatus             string                       `json:"accelerateStatus,omitempty"`
	RequestPaymentPayer          string                       `json:"requestPaymentPayer,omitempty"`
	Tags                         []types.Tag                  `json:"tags,omitempty"`
	DeletePending                bool                         `json:"deletePending,omitempty"`
	IsDirectoryBucket            bool                         `json:"isDirectoryBucket,omitempty"`
	// contains filtered or unexported fields
}

StoredBucket represents an S3 bucket in memory.

Region is the region the bucket was created in. It is the store.Table key function's identity companion: buckets are keyed by Name (globally unique — CreateBucket enforces this across all regions, mirroring real S3's global bucket-namespace), so Region moved here from the old region->name->*StoredBucket nesting to make that identity self-contained. It never changes after creation (S3 has no "move bucket to another region" operation).

type StoredMultipartUpload

type StoredMultipartUpload struct {
	Initiated time.Time             `json:"initiated"`
	Parts     map[int32]*StoredPart `json:"parts,omitempty"`

	UploadID string `json:"uploadID"`
	Bucket   string `json:"bucket"`
	Key      string `json:"key"`
	// Tagging holds the URL-encoded tag string from the X-Amz-Tagging header
	// supplied at CreateMultipartUpload time. It is applied to the resulting
	// object version when CompleteMultipartUpload succeeds.
	Tagging string `json:"tagging,omitempty"`
	// SSE captures the encryption headers from CreateMultipartUpload so the
	// completed object's assembled body can be sealed with the same envelope
	// (matching real S3 — SSE is fixed at session-init). Persisted so that an
	// in-flight upload that survives a snapshot/restore still completes with
	// the caller's chosen encryption rather than silently landing unencrypted.
	// (The SSE-C customer key inside sseInfo stays request-scoped — see
	// sseInfo.SSECKeyB64 — so SSE-C uploads still require the key on Complete.)
	SSE sseInfo `json:"sse"`
	// contains filtered or unexported fields
}

StoredMultipartUpload represents an ongoing multipart upload session.

type StoredObject

type StoredObject struct {
	Versions map[string]*StoredObjectVersion `json:"versions,omitempty"`

	Key             string `json:"key"`
	LatestVersionID string `json:"latestVersionID"`
	// contains filtered or unexported fields
}

StoredObject represents an S3 object with its version history.

type StoredObjectVersion

type StoredObjectVersion struct {
	LastModified      time.Time         `json:"lastModified"`
	RetainUntil       time.Time         `json:"retainUntil"`
	RestoreExpiry     time.Time         `json:"restoreExpiry,omitzero"`
	ChecksumSHA1      *string           `json:"checksumSHA1,omitempty"`
	Metadata          map[string]string `json:"metadata,omitempty"`
	ChecksumSHA256    *string           `json:"checksumSHA256,omitempty"`
	ChecksumCRC32     *string           `json:"checksumCRC32,omitempty"`
	ChecksumCRC32C    *string           `json:"checksumCRC32C,omitempty"`
	ChecksumCRC64NVME *string           `json:"checksumCRC64NVME,omitempty"`
	SSEAlgorithm      string            `json:"sseAlgorithm,omitempty"`
	SSEKMSKeyID       string            `json:"sseKMSKeyID,omitempty"`
	SSECAlgorithm     string            `json:"sseCAlgorithm,omitempty"`
	SSECKeyMD5        string            `json:"sseCKeyMD5,omitempty"`
	// EncryptionDEK is the AES-256 data encryption key randomly generated on
	// PUT for SSE-S3/SSE-KMS objects. Real S3 wraps this under a KMS CMK and
	// stores only the wrapped form; for an in-memory mock the storage is
	// the same address space so we keep the raw key. SSE-C objects don't
	// store the key — the customer re-supplies it on GET. It MUST persist:
	// the ciphertext lives in Data (persisted), so dropping the DEK on a
	// snapshot/restore would leave every SSE-S3/SSE-KMS object permanently
	// undecryptable ([]byte round-trips as base64 under encoding/json).
	EncryptionDEK []byte `json:"encryptionDEK,omitempty"`
	// EncryptionNonce is the GCM nonce/IV used for this object's ciphertext.
	// Stored alongside the ciphertext (in StoredObjectVersion.Data) so GET
	// can decrypt without re-deriving anything. Persisted for the same reason
	// as EncryptionDEK.
	EncryptionNonce         []byte                   `json:"encryptionNonce,omitempty"`
	Key                     string                   `json:"key"`
	ETag                    string                   `json:"etag"`
	ContentType             string                   `json:"contentType"`
	ContentEncoding         string                   `json:"contentEncoding,omitempty"`
	ContentDisposition      string                   `json:"contentDisposition,omitempty"`
	RetentionMode           string                   `json:"retentionMode,omitempty"`
	StorageClass            string                   `json:"storageClass,omitempty"`
	ACL                     string                   `json:"acl,omitempty"`
	ChecksumAlgorithm       types.ChecksumAlgorithm  `json:"checksumAlgorithm,omitempty"`
	VersionID               string                   `json:"versionID"`
	Data                    []byte                   `json:"data,omitempty"`
	StorageClassTransitions []StorageClassTransition `json:"storageClassTransitions,omitempty"`
	Size                    int64                    `json:"size"`
	IsCompressed            bool                     `json:"isCompressed,omitempty"`
	IsLatest                bool                     `json:"isLatest"`
	Deleted                 bool                     `json:"deleted,omitempty"`
	LegalHold               bool                     `json:"legalHold,omitempty"`
	OngoingRestore          bool                     `json:"ongoingRestore,omitempty"`
}

StoredObjectVersion represents a specific version of an S3 object.

type StoredPart

type StoredPart struct {
	ETag       string `json:"etag"`
	Data       []byte `json:"data,omitempty"`
	PartNumber int32  `json:"partNumber"`
	Size       int64  `json:"size"`
}

StoredPart represents a single part of a multipart upload.

type Tag

type Tag struct {
	Key   string `xml:"Key"`
	Value string `xml:"Value"`
}

type TagSet

type TagSet struct {
	Tags []Tag `xml:"Tag"`
}

type Tagging

type Tagging struct {
	XMLName xml.Name `xml:"Tagging"`
	TagSet  TagSet   `xml:"TagSet"`
}

type UploadPartCopyResult

type UploadPartCopyResult struct {
	XMLName      xml.Name `xml:"CopyPartResult"`
	LastModified string   `xml:"LastModified"`
	ETag         string   `xml:"ETag"`
}

type VersioningConfiguration

type VersioningConfiguration struct {
	XMLName xml.Name `xml:"VersioningConfiguration"`
	Status  string   `xml:"Status,omitempty"` // "Enabled" or "Suspended"; omitted when versioning is not yet configured
}

type WebsiteConfiguration

type WebsiteConfiguration struct {
	XMLName               xml.Name              `xml:"WebsiteConfiguration"`
	Xmlns                 string                `xml:"xmlns,attr,omitempty"`
	IndexDocument         *WebsiteIndexDocument `xml:"IndexDocument,omitempty"`
	ErrorDocument         *WebsiteErrorDocument `xml:"ErrorDocument,omitempty"`
	RedirectAllRequestsTo *WebsiteRedirectAll   `xml:"RedirectAllRequestsTo,omitempty"`
	RoutingRules          []WebsiteRoutingRule  `xml:"RoutingRules>RoutingRule,omitempty"`
}

WebsiteConfiguration is the XML body for PutBucketWebsite / GetBucketWebsite.

type WebsiteErrorDocument

type WebsiteErrorDocument struct {
	Key string `xml:"Key"`
}

WebsiteErrorDocument specifies the object to return on 4XX errors.

type WebsiteIndexDocument

type WebsiteIndexDocument struct {
	Suffix string `xml:"Suffix"`
}

WebsiteIndexDocument specifies the suffix of the object used as an index.

type WebsiteRedirectAll

type WebsiteRedirectAll struct {
	HostName string `xml:"HostName"`
	Protocol string `xml:"Protocol,omitempty"`
}

WebsiteRedirectAll configures a redirect for all requests to a given host.

type WebsiteRoutingRule

type WebsiteRoutingRule struct {
	Condition *WebsiteRoutingRuleCondition `xml:"Condition,omitempty"`
	Redirect  WebsiteRoutingRuleRedirect   `xml:"Redirect"`
}

WebsiteRoutingRule is a single conditional routing rule.

type WebsiteRoutingRuleCondition

type WebsiteRoutingRuleCondition struct {
	KeyPrefixEquals             string `xml:"KeyPrefixEquals,omitempty"`
	HTTPErrorCodeReturnedEquals string `xml:"HttpErrorCodeReturnedEquals,omitempty"`
}

WebsiteRoutingRuleCondition specifies the condition for a routing rule.

type WebsiteRoutingRuleRedirect

type WebsiteRoutingRuleRedirect struct {
	HostName             string `xml:"HostName,omitempty"`
	Protocol             string `xml:"Protocol,omitempty"`
	ReplaceKeyPrefixWith string `xml:"ReplaceKeyPrefixWith,omitempty"`
	ReplaceKeyWith       string `xml:"ReplaceKeyWith,omitempty"`
	HTTPRedirectCode     string `xml:"HttpRedirectCode,omitempty"`
}

WebsiteRoutingRuleRedirect specifies the redirect target for a routing rule.

Jump to

Keyboard shortcuts

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