s3

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 68 Imported by: 0

README

S3

Parity grade: A · SDK aws-sdk-go-v2/service/s3@v1.111.0 · last audited 2026-09-24 (30db30dd8) · protocol REST-XML

Coverage

Metric Value
PARITY entries audited 26 (25 ok, 1 gap)
Feature families 8 (8 ok)
Known gaps 7
Deferred items 0
Resource leaks clean
Known gaps
  • AWS/S3 request metrics are emitted per bucket metrics configuration (FilterId; key-prefix filters honoured, tag filters not); FirstByteLatency, SelectRequests/SelectBytes*, replication and per-storage-class request metrics are not. (gopherstack-4m1qr)
  • GetBucketMetadataConfiguration echoes the CREATE body instead of a MetadataConfigurationResult with a server-computed DestinationResult; needs S3 Tables table-bucket ARN/namespace/status modeling (gopherstack-6flj).
  • Rejections the pinned SDK lists no error code for, so none is invented: Object Annotations 1 B-1 MiB payload window and ObjectIfMatch; RenameObject and CreateSession accepted on non-directory buckets; CreateSession SessionMode ReadOnly not enforced; directory buckets still accept ACL/tagging/versioning/lifecycle/website/CORS.
  • Accepted but not applied (no model behind them): PutObject x-amz-write-offset-bytes (append needs re-sealing the compressed/encrypted body), List* x-amz-optional-object-attributes (RestoreStatus is not carried by the listing slab), x-amz-mfa (MFA delete is stored, never enforced), CreateBucket x-amz-bucket-namespace, PutBucketPolicy x-amz-confirm-remove-self-bucket-access, and the MD5, SHA512 and XXHASH checksum algorithms.
  • ListBucketIntelligentTieringConfigurations is unpaginated (the SDK documents no page size).
  • object_lambda: GetObject only resolves a Lambda wired by bucket name, not access-point-ARN routing; needs ARN-as-bucket routing on every route plus an s3control lookup.
  • Notification destinations are validated only at PutBucketNotificationConfiguration; per-configuration error details are not emitted (2026-10-03).

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")
	// ErrMpuObjectSizeMismatch is the 400 InvalidRequest documented for x-amz-mp-object-size.
	ErrMpuObjectSizeMismatch = 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")
	// ErrObjectLockNotEnabled is InvalidBucketState: PutObjectLockConfiguration
	// on a bucket not created with x-amz-bucket-object-lock-enabled: true.
	ErrObjectLockNotEnabled = errors.New("InvalidBucketState")
	ErrNoWebsiteConfig      = errors.New("NoSuchWebsiteConfiguration")
	ErrNoEncryptionConfig   = errors.New("ServerSideEncryptionConfigurationNotFoundError")
	ErrObjectLocked         = errors.New(errAccessDenied)
	ErrInvalidObjectState   = errors.New("InvalidObjectState")
	// ErrRetentionPeriodShortened is returned by PutObjectRetention when the
	// proposed retain-until date is earlier than the object's current one and
	// the change isn't an authorized GOVERNANCE bypass. Real S3 never allows
	// this for COMPLIANCE mode, for any principal.
	ErrRetentionPeriodShortened = errors.New("RetentionPeriodShortened")
	// ErrRetentionModeDowngrade is returned by PutObjectRetention when a
	// COMPLIANCE-mode object's retention mode is changed to anything else.
	// Real S3 never allows this, with or without a bypass header.
	ErrRetentionModeDowngrade     = errors.New("RetentionModeDowngrade")
	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)
	// ErrMalformedPolicy is returned when a PutBucketPolicy body is not valid
	// JSON. The error table maps it to HTTP 400 with code "MalformedPolicy",
	// matching real S3.
	ErrMalformedPolicy = errors.New("MalformedPolicy")
	// ErrListObjectsNotSupportedForDirectoryBucket is returned by ListObjects
	// (V1) on a directory bucket: real S3 documents it as "not supported for
	// directory buckets" (s3@v1.111.0 api_op_ListObjects.go:13) -- callers
	// must use ListObjectsV2 instead.
	ErrListObjectsNotSupportedForDirectoryBucket = errors.New(
		"ListObjects is not supported for directory buckets")
	// ErrDirectoryBucketDelimiter is returned by ListObjectsV2 on a directory
	// bucket when Delimiter is set to anything other than "/".
	ErrDirectoryBucketDelimiter = errors.New("directory buckets only support delimiter \"/\"")

	// ErrAnnotationLimitExceeded and the Object Annotations errors below it
	// carry codes verified against s3@v1.106.5 deserializers.go's per-op error
	// switches: PutObjectAnnotation declares AnnotationLimitExceeded,
	// AnnotationNameTooLong, InvalidAnnotationName, InvalidRequest, NoSuchBucket,
	// NoSuchKey, UnsupportedMediaType; GetObjectAnnotation declares NoSuchAnnotation,
	// NoSuchBucket, NoSuchKey; ListObjectAnnotations declares InvalidPrefix,
	// NoSuchBucket, NoSuchKey. DeleteObjectAnnotation's switch declares only
	// NoSuchBucket/NoSuchKey -- deliberately no ErrNoSuchAnnotation there, see
	// DeleteObjectAnnotation in annotations.go.
	ErrAnnotationLimitExceeded        = errors.New("AnnotationLimitExceeded")
	ErrAnnotationNameTooLong          = errors.New("AnnotationNameTooLong")
	ErrInvalidAnnotationName          = errors.New("InvalidAnnotationName")
	ErrNoSuchAnnotation               = awserr.New("NoSuchAnnotation", awserr.ErrNotFound)
	ErrAnnotationUnsupportedMediaType = errors.New("UnsupportedMediaType")
	ErrInvalidAnnotationPrefix        = errors.New("InvalidPrefix")
	// ErrAnnotationSSECNotSupported reuses the "InvalidRequest" code (declared
	// on PutObjectAnnotation's switch) for the documented restriction "Objects
	// encrypted with SSE-C cannot have annotations" (s3@v1.106.5
	// api_op_PutObjectAnnotation.go doc comment).
	ErrAnnotationSSECNotSupported = errors.New("InvalidRequest")
)
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 NewCRC32C

func NewCRC32C() hash.Hash32

NewCRC32C returns a new CRC32C (Castagnoli) hash using the pre-computed table.

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"`
	// BucketRegion is the literal region the bucket lives in (see
	// InMemoryBackend.ListBuckets in buckets.go for why it's always populated
	// here, and why -- unlike GetBucketLocation's LocationConstraint -- it is
	// never blanked out for us-east-1).
	BucketRegion string `xml:"BucketRegion"`
}

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"`
	ChecksumCRC32     string   `xml:"ChecksumCRC32,omitempty"`
	ChecksumCRC32C    string   `xml:"ChecksumCRC32C,omitempty"`
	ChecksumCRC64NVME string   `xml:"ChecksumCRC64NVME,omitempty"`
	ChecksumSHA1      string   `xml:"ChecksumSHA1,omitempty"`
	ChecksumSHA256    string   `xml:"ChecksumSHA256,omitempty"`
}

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"`
	EmailAddress string `xml:"EmailAddress,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 {
	// contains filtered or unexported fields
}

GzipCompressor is the legacy gzip codec; it also decodes zstd blobs.

func (*GzipCompressor) Compress

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

Compress gzips data at BestSpeed. Compression is an internal storage-format choice (GetObject always decompresses back to the exact original bytes), so trading ratio for speed here is invisible to callers; DefaultCompression's CPU cost dominated the object-write hot path under profiling. The buffer is not pre-sized to len(data): output is usually much smaller.

func (*GzipCompressor) CompressParts

func (c *GzipCompressor) CompressParts(parts [][]byte) ([]byte, error)

CompressParts gzips the concatenation of parts without materialising it.

func (*GzipCompressor) Decompress

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

Decompress decodes a gzip or zstd blob, chosen by magic bytes.

func (*GzipCompressor) DecompressRange

func (c *GzipCompressor) DecompressRange(data []byte, size, start, end int64) ([]byte, bool, error)

DecompressRange decodes a byte window of a seekable zstd blob.

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 or is pending async deletion. 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) CopyObjectAnnotations

func (b *InMemoryBackend) CopyObjectAnnotations(
	srcBucket, srcKey string, srcVersionID *string,
	destBucket, destKey string, destVersionID *string,
) error

CopyObjectAnnotations copies every annotation from the source object version onto the destination version, implementing CopyObjectInput.AnnotationDirective's default COPY behavior (s3@v1.111.0 api_op_CopyObject.go doc: "annotations are copied unless ... EXCLUDE"). The CopyObject handler calls this after its own PutObject has already landed the destination version, so a missing source or destination object here is unexpected rather than a normal race; either is treated as "nothing to copy" rather than failing an already-succeeded copy.

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(
	ctx context.Context, bucketName string, mode types.SessionMode,
) (SessionCredentials, error)

CreateSession issues temporary session credentials scoped to bucketName, expiring s3ExpressSessionTTL from now. SessionMode is accepted but not enforced (this emulator does not model IAM-policy-scoped ReadOnly vs ReadWrite sessions).

Deliberately does NOT require bucketName to already exist: the pinned SDK (s3@v1.111.0) issues an implicit CreateSession as part of its own identity resolution for ANY operation on a directory-bucket-shaped name when a custom BaseEndpoint is configured -- including CreateBucket itself, before the bucket exists. Confirmed with a real client against a dumping httptest.Server: CreateBucket's own bindEndpointParams never sets DisableS3ExpressSessionAuth, so with a custom endpoint the SDK's endpoint ruleset routes it through the session-credential auth scheme regardless (case selection differs only when there is no endpoint override, i.e. real, unmodified AWS, where CreateBucket needs no session at all). This is a structural client-side quirk of driving S3Express-classified operations through a custom endpoint, not a real permission gate this emulator has any other way to model -- bucket existence is still enforced by every actual operation (CreateBucket, PutObject, etc.), just not by this bootstrapping step.

func (*InMemoryBackend) CreateSessionWithEncryption

func (b *InMemoryBackend) CreateSessionWithEncryption(
	_ context.Context, bucketName string, _ types.SessionMode, enc SessionEncryption,
) (SessionCredentials, error)

CreateSessionWithEncryption is CreateSession with a session-level default SSE configuration.

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) DeleteObjectAnnotation added in v1.3.1

DeleteObjectAnnotation removes a named annotation from an object version. Deleting a name that doesn't exist is not an error: DeleteObjectAnnotation's error switch (s3@v1.106.5 deserializers.go) declares only NoSuchBucket and NoSuchKey -- no NoSuchAnnotation -- matching real S3's idempotent-delete semantics for DeleteObject itself.

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) EmitStorageMetrics

func (b *InMemoryBackend) EmitStorageMetrics()

EmitStorageMetrics publishes BucketSizeBytes (per StorageType) and NumberOfObjects for every bucket.

func (*InMemoryBackend) ExpressSessionEncryption

func (b *InMemoryBackend) ExpressSessionEncryption(accessKeyID, sessionToken string) (SessionEncryption, bool)

ExpressSessionEncryption returns the SSE defaults of a live session.

func (*InMemoryBackend) ExpressSessionSecret

func (b *InMemoryBackend) ExpressSessionSecret(accessKeyID, sessionToken string) (string, string, bool)

ExpressSessionSecret looks up a live (non-expired) S3 Express session by its AccessKeyID and session token, returning the bucket it is scoped to and its secret key. A missing, mismatched, or expired session is reported as not found; an expired entry is also deleted.

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) GetBucketLifecycleTransitionDefaultMinObjectSize

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

GetBucketLifecycleTransitionDefaultMinObjectSize returns the bucket's stored X-Amz-Transition-Default-Minimum-Object-Size value (s3@v1.111.0 deserializers.go:4579, echoed on GetBucketLifecycleConfiguration's response), "" when never set.

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) GetBucketOwnerAccount

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

GetBucketOwnerAccount returns the account ID that created bucketName. Buckets persisted before this field existed default to awsmeta.DefaultAccount.

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) GetObjectAnnotation added in v1.3.1

GetObjectAnnotation retrieves a single named annotation from an object version.

func (*InMemoryBackend) GetObjectAttributes

func (b *InMemoryBackend) GetObjectAttributes(
	_ context.Context,
	bucketName, key, versionID string,
	maxParts, partNumberMarker int32,
) (*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) IsDirectoryBucket

func (b *InMemoryBackend) IsDirectoryBucket(bucketName string) bool

IsDirectoryBucket reports whether bucket is an S3 Express directory bucket. Returns false for general-purpose buckets and for buckets that don't exist (existence is the caller's own concern).

func (*InMemoryBackend) ListBucketAnalyticsConfigurations

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

ListBucketAnalyticsConfigurations returns all analytics configurations for a bucket, ordered by ID.

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 (b *InMemoryBackend) ListBuckets(
	_ context.Context,
	input *s3.ListBucketsInput,
) (*s3.ListBucketsOutput, error)

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) ListObjectAnnotations added in v1.3.1

ListObjectAnnotations lists the annotations attached to an object version, optionally filtered by name prefix and paginated via ContinuationToken.

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) MergeBucketTags added in v1.3.1

func (b *InMemoryBackend) MergeBucketTags(bucketName string, newTags map[string]string) error

MergeBucketTags adds/overwrites tags in a bucket's existing tag set. Unlike PutBucketTagging (which replaces the whole set, matching real S3's PutBucketTagging semantics), this merges -- the semantics Resource Groups Tagging API's TagResources needs.

func (*InMemoryBackend) ObjectLambdaConfig

func (b *InMemoryBackend) ObjectLambdaConfig(bucketName string) string

ObjectLambdaConfig returns the Lambda ARN configured for GetObject on bucketName, or "" if none is configured or the bucket doesn't exist.

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, transitionDefaultMinObjectSize string,
) error

PutBucketLifecycleConfiguration stores the lifecycle configuration for a bucket. transitionDefaultMinObjectSize is the X-Amz-Transition-Default-Minimum-Object-Size header value (s3@v1.111.0 serializers.go:7411); empty when the caller didn't set it.

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) PutObjectAnnotation added in v1.3.1

func (b *InMemoryBackend) PutObjectAnnotation(
	ctx context.Context,
	input *s3.PutObjectAnnotationInput,
) (*s3.PutObjectAnnotationOutput, error)

PutObjectAnnotation attaches a named annotation to an object 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,
	bypassGovernance bool,
) 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) RemoveBucketTags added in v1.3.1

func (b *InMemoryBackend) RemoveBucketTags(bucketName string, keys []string) error

RemoveBucketTags deletes specific tag keys from a bucket's tag set, for Resource Groups Tagging API's UntagResources.

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) RequestMetricFilters

func (b *InMemoryBackend) RequestMetricFilters(name string) (string, []MetricsFilter)

RequestMetricFilters returns the bucket's region and its metrics configurations (none when absent).

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) SetMetricEmitter

func (b *InMemoryBackend) SetMetricEmitter(e cwmetric.Emitter)

SetMetricEmitter sets the emitter used for the daily storage metrics.

func (*InMemoryBackend) SetObjectLambdaConfig

func (b *InMemoryBackend) SetObjectLambdaConfig(bucketName, lambdaARN string)

SetObjectLambdaConfig stores lambdaARN on bucket's own record under the bucket's coarse lock, mirroring how every other sub-resource config (CORS, policy, lifecycle, ...) is stored -- see cors.go. A no-op if the bucket doesn't exist (or is pending deletion): the config is cleared implicitly once the bucket record itself is removed, so a bucket recreated under the same name never inherits a prior incarnation's Lambda wiring.

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) TaggedResources added in v1.3.1

func (b *InMemoryBackend) TaggedResources() []TaggedEntry

TaggedResources returns every bucket's tag set keyed by its ARN. Real S3 object ARNs are excluded: GetResources's own ResourceTypeFilters documentation only ever gives "s3:bucket" as the S3 example (botocore 1.43.56, resourcegroupstaggingapi/2017-01-26/service-2.json.gz, GetResourcesInput.ResourceTypeFilters), and objects have no such type.

func (*InMemoryBackend) UpdateBucketMetadataAnnotationTableConfig added in v1.3.1

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

UpdateBucketMetadataAnnotationTableConfig stores the annotation table configuration XML for an S3 Metadata configuration (real key "metadataAnnotationTable" -- verified against s3@v1.106.5 serializers.go: awsRestxml_serializeOpUpdateBucketMetadataAnnotationTableConfiguration's httpbinding.SplitURI("/?metadataAnnotationTable")). There is no dedicated Get op for this sub-config in the pinned SDK; it is exposed to the caller, if at all, nested inside GetBucketMetadataConfiguration's body, matching how the sibling inventory/journal table configs already behave here.

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 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"`
	ContinuationToken string      `xml:"ContinuationToken,omitempty"`
	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 MetricsFilter

type MetricsFilter struct {
	ID     string
	Prefix string
}

MetricsFilter is one bucket metrics configuration: its FilterId and optional key prefix.

type MultipartUpload

type MultipartUpload struct {
	Initiated    time.Time `xml:"Initiated"`
	Owner        *Owner    `xml:"Owner,omitempty"`
	Initiator    *Owner    `xml:"Initiator,omitempty"`
	Key          string    `xml:"Key"`
	UploadID     string    `xml:"UploadId"`
	StorageClass string    `xml:"StorageClass,omitempty"`
}

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)
	// DispatchObjectPosted sends an s3:ObjectCreated:Post notification for a
	// browser-style POST Object upload.
	DispatchObjectPosted(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
	Parts        *ObjectPartsAttributes
	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 ObjectPartsAttributes added in v1.3.1

type ObjectPartsAttributes struct {
	Parts                []StoredObjectPart
	TotalPartsCount      int32
	PartNumberMarker     int32
	NextPartNumberMarker int32
	MaxParts             int32
	IsTruncated          bool
}

ObjectPartsAttributes contains multipart upload parts breakdown for GetObjectAttributes.

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"`
	ChecksumAlgorithm string `xml:"ChecksumAlgorithm,omitempty"`
	Size              int64  `xml:"Size"`
	IsLatest          bool   `xml:"IsLatest"`
}

type ObjectXML

type ObjectXML struct {
	Owner             *Owner `xml:"Owner"`
	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"`
	ChecksumCRC32     string `xml:"ChecksumCRC32,omitempty"`
	ChecksumCRC32C    string `xml:"ChecksumCRC32C,omitempty"`
	ChecksumCRC64NVME string `xml:"ChecksumCRC64NVME,omitempty"`
	ChecksumSHA1      string `xml:"ChecksumSHA1,omitempty"`
	ChecksumSHA256    string `xml:"ChecksumSHA256,omitempty"`
	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 {
	Filter                  *ReplicationRuleFilter  `xml:"Filter,omitempty"`
	Destination             ReplicationDestination  `xml:"Destination"`
	DeleteMarkerReplication DeleteMarkerReplication `xml:"DeleteMarkerReplication"`
	ID                      string                  `xml:"ID,omitempty"`
	// Prefix is the legacy (deprecated) top-level filter field. Modern
	// configurations use Filter>Prefix instead -- see matchesReplicationRule
	// in replication.go, which checks Filter first and falls back to this.
	Prefix string `xml:"Prefix,omitempty"`
	Status string `xml:"Status"`
}

ReplicationRule is a single replication rule within a ReplicationConfiguration.

type ReplicationRuleFilter added in v1.3.1

type ReplicationRuleFilter struct {
	Prefix *string `xml:"Prefix,omitempty"`
	Tag    *Tag    `xml:"Tag,omitempty"`
}

ReplicationRuleFilter identifies the subset of objects a replication rule applies to. Real S3 requires exactly one of Prefix/Tag/And to be set (see aws-sdk-go-v2/service/s3/types.ReplicationRuleFilter's doc comment); And-based composite (multi-tag/prefix+tag) filters are not evaluated by this emulator (see matchesReplicationRule) and are a documented gap.

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) SetMetricEmitter

func (h *S3Handler) SetMetricEmitter(e cwmetric.Emitter)

SetMetricEmitter sets the emitter used for request metrics.

func (*S3Handler) SetNotificationAuthorizer

func (h *S3Handler) SetNotificationAuthorizer(a roleauth.Authorizer)

SetNotificationAuthorizer makes PutBucketNotificationConfiguration reject destinations whose resource policy does not allow s3.amazonaws.com from the bucket.

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. Satisfies services/s3control's ObjectLambdaConfigSink interface.

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 SessionCredentials

type SessionCredentials struct {
	Expiration      time.Time
	AccessKeyID     string
	SecretAccessKey string
	SessionToken    string
}

SessionCredentials is the temporary credential set CreateSession issues, scoped to one directory bucket.

type SessionEncryption

type SessionEncryption struct {
	BucketKeyEnabled *bool
	Algorithm        string
	KMSKeyID         string
	KMSContext       string
}

SessionEncryption is the default server-side encryption a CreateSession applies to objects stored through it.

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, transitionDefaultMinObjectSize string,
	) error
	GetBucketLifecycleConfiguration(ctx context.Context, bucket string) (string, error)
	GetBucketLifecycleTransitionDefaultMinObjectSize(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,
		bypassGovernance bool,
	) 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 (S3 Express One Zone)
	CreateSession(ctx context.Context, bucket string, sessionMode types.SessionMode) (SessionCredentials, error)
	CreateSessionWithEncryption(
		ctx context.Context, bucket string, sessionMode types.SessionMode, enc SessionEncryption,
	) (SessionCredentials, error)
	ExpressSessionEncryption(accessKeyID, sessionToken string) (SessionEncryption, bool)
	ExpressSessionSecret(accessKeyID, sessionToken string) (bucket, secret string, ok bool)
	IsDirectoryBucket(bucket string) bool

	// 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)
	GetBucketOwnerAccount(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)

	// Object Lambda: the Lambda ARN a completed s3control
	// CreateAccessPointForObjectLambda/PutAccessPointConfigurationForObjectLambda
	// resolves to for the underlying bucket (see ObjectLambdaConfigSink in
	// services/s3control). Stored per-bucket under the bucket's own coarse lock,
	// so it is cleared automatically once the bucket record is removed.
	SetObjectLambdaConfig(bucket, lambdaARN string)
	ObjectLambdaConfig(bucket string) string

	// 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
	UpdateBucketMetadataAnnotationTableConfig(ctx context.Context, bucket, configXML string) error

	// Object Annotations
	PutObjectAnnotation(
		ctx context.Context,
		input *s3.PutObjectAnnotationInput,
	) (*s3.PutObjectAnnotationOutput, error)
	GetObjectAnnotation(
		ctx context.Context,
		input *s3.GetObjectAnnotationInput,
	) (*s3.GetObjectAnnotationOutput, error)
	DeleteObjectAnnotation(
		ctx context.Context,
		input *s3.DeleteObjectAnnotationInput,
	) (*s3.DeleteObjectAnnotationOutput, error)
	ListObjectAnnotations(
		ctx context.Context,
		input *s3.ListObjectAnnotationsInput,
	) (*s3.ListObjectAnnotationsOutput, error)
	CopyObjectAnnotations(
		srcBucket, srcKey string, srcVersionID *string,
		destBucket, destKey string, destVersionID *string,
	) error

	// GetObjectAttributes / RestoreObject / RenameObject
	GetObjectAttributes(
		ctx context.Context,
		bucket, key, versionID string,
		maxParts, partNumberMarker int32,
	) (*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 StoredAnnotation added in v1.3.1

type StoredAnnotation struct {
	LastModified      time.Time               `json:"lastModified"`
	Name              string                  `json:"name"`
	ETag              string                  `json:"etag"`
	ChecksumAlgorithm types.ChecksumAlgorithm `json:"checksumAlgorithm,omitempty"`
	ChecksumCRC32     *string                 `json:"checksumCRC32,omitempty"`
	ChecksumCRC32C    *string                 `json:"checksumCRC32C,omitempty"`
	ChecksumSHA1      *string                 `json:"checksumSHA1,omitempty"`
	ChecksumSHA256    *string                 `json:"checksumSHA256,omitempty"`
	ChecksumCRC64NVME *string                 `json:"checksumCRC64NVME,omitempty"`
	Payload           []byte                  `json:"payload"`
}

StoredAnnotation represents a single named annotation attached to an object version (PutObjectAnnotation / GetObjectAnnotation / ListObjectAnnotations).

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"`
	TransitionDefaultMinObjectSize string                       `json:"transitionDefaultMinObjectSize,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"`
	ObjectLambdaConfig             string                       `json:"objectLambdaConfig,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"`
	MetadataAnnotationTableConfig  string                       `json:"metadataAnnotationTableConfig,omitempty"`
	MetricsConfigs                 map[string]string            `json:"metricsConfigs,omitempty"`
	Versioning                     types.BucketVersioningStatus `json:"versioning,omitempty"`
	// MFADelete is stored as a plain string, not a typed SDK enum, because the
	// real request and response shapes use two DIFFERENT Go types for the same
	// concept (VersioningConfiguration.MFADelete is types.MFADelete;
	// GetBucketVersioningOutput.MFADelete is types.MFADeleteStatus,
	// s3@v1.106.5 api_op_GetBucketVersioning.go/types/enums.go) -- both hold
	// the same "Enabled"/"Disabled" strings on the wire.
	MFADelete           string `json:"mfaDelete,omitempty"`
	Name                string `json:"name"`
	ACL                 string `json:"acl,omitempty"`
	AccelerateStatus    string `json:"accelerateStatus,omitempty"`
	RequestPaymentPayer string `json:"requestPaymentPayer,omitempty"`
	// OwnerAccountID is the account that called CreateBucket (awsmeta.Account
	// at creation time). Requester-Pays enforcement exempts this account from
	// the x-amz-request-payer header requirement (services/s3/requester_pays.go).
	OwnerAccountID    string      `json:"ownerAccountID,omitempty"`
	Tags              []types.Tag `json:"tags,omitempty"`
	DeletePending     bool        `json:"deletePending,omitempty"`
	IsDirectoryBucket bool        `json:"isDirectoryBucket,omitempty"`
	// ObjectLockEnabled records whether CreateBucket was called with
	// x-amz-bucket-object-lock-enabled: true. Real S3 requires this at bucket
	// creation before PutObjectLockConfiguration will accept a configuration
	// (gopherstack-pzth) -- it cannot be turned on for an existing bucket.
	ObjectLockEnabled bool `json:"objectLockEnabled,omitempty"`
	// contains filtered or unexported fields
}

StoredBucket represents an S3 bucket in memory.

Buckets are keyed by Name (globally unique -- CreateBucket enforces this across all regions, mirroring real S3's global bucket-namespace). Region never changes after creation (S3 has no "move bucket to another region" operation).

func (*StoredBucket) MarshalJSON

func (bucket *StoredBucket) MarshalJSON() ([]byte, error)

MarshalJSON serialises the bucket under bucket.mu.RLock so Snapshot can't race PutObject/PutBucketWebsite/etc. Those mutate bucket fields under bucket.mu without ever taking b.mu (gopherstack-fwd0g).

type StoredMultipartUpload

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

	SSE sseInfo `json:"sse"`
	// Headers are the object headers and user metadata chosen at CreateMultipartUpload.
	Headers      multipartObjectHeaders `json:"headers,omitzero"`
	UploadID     string                 `json:"uploadID"`
	Bucket       string                 `json:"bucket"`
	Key          string                 `json:"key"`
	Tagging      string                 `json:"tagging,omitempty"`
	StorageClass string                 `json:"storageClass,omitempty"`
	ACL          string                 `json:"acl,omitempty"`
	// contains filtered or unexported fields
}

StoredMultipartUpload represents an ongoing multipart upload session.

func (*StoredMultipartUpload) MarshalJSON

func (u *StoredMultipartUpload) MarshalJSON() ([]byte, error)

MarshalJSON serialises the upload under its own mu.RLock so Snapshot can't race storePart/CompleteMultipartUpload. Those mutate upload fields under upload.mu without ever taking b.mu.

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.

func (*StoredObject) MarshalJSON

func (obj *StoredObject) MarshalJSON() ([]byte, error)

MarshalJSON serialises the object under obj.mu.RLock, nested under the caller's bucket.mu.RLock -- see StoredBucket.MarshalJSON.

type StoredObjectPart added in v1.3.1

type StoredObjectPart struct {
	ChecksumCRC32     *string `json:"checksumCRC32,omitempty"`
	ChecksumCRC32C    *string `json:"checksumCRC32C,omitempty"`
	ChecksumCRC64NVME *string `json:"checksumCRC64NVME,omitempty"`
	ChecksumSHA1      *string `json:"checksumSHA1,omitempty"`
	ChecksumSHA256    *string `json:"checksumSHA256,omitempty"`
	PartNumber        int32   `json:"partNumber"`
	Size              int64   `json:"size"`
}

StoredObjectPart represents metadata for an individual completed multipart upload part.

type StoredObjectVersion

type StoredObjectVersion struct {
	RetainUntil   time.Time `json:"retainUntil"`
	RestoreExpiry time.Time `json:"restoreExpiry,omitzero"`
	LastModified  time.Time `json:"lastModified"`
	// Expires is the object's Expires header (PutObject/CopyObject/
	// CreateMultipartUpload, s3@v1.111.0 serializers.go:461,1032,8598), sent as
	// HTTP-date and echoed verbatim by GetObject/HeadObject
	// (deserializers.go:6936,8899). Zero means unset (header omitted).
	Expires                 time.Time                    `json:"expires,omitzero"`
	ChecksumSHA1            *string                      `json:"checksumSHA1,omitempty"`
	Metadata                map[string]string            `json:"metadata,omitempty"`
	Annotations             map[string]*StoredAnnotation `json:"annotations,omitempty"`
	ChecksumCRC64NVME       *string                      `json:"checksumCRC64NVME,omitempty"`
	ChecksumCRC32C          *string                      `json:"checksumCRC32C,omitempty"`
	ChecksumCRC32           *string                      `json:"checksumCRC32,omitempty"`
	ChecksumSHA256          *string                      `json:"checksumSHA256,omitempty"`
	SSEAlgorithm            string                       `json:"sseAlgorithm,omitempty"`
	VersionID               string                       `json:"versionID"`
	ChecksumAlgorithm       types.ChecksumAlgorithm      `json:"checksumAlgorithm,omitempty"`
	SSECKeyMD5              string                       `json:"sseCKeyMD5,omitempty"`
	SSECAlgorithm           string                       `json:"sseCAlgorithm,omitempty"`
	Key                     string                       `json:"key"`
	ETag                    string                       `json:"etag"`
	ContentType             string                       `json:"contentType"`
	ContentEncoding         string                       `json:"contentEncoding,omitempty"`
	ContentDisposition      string                       `json:"contentDisposition,omitempty"`
	CacheControl            string                       `json:"cacheControl,omitempty"`
	ContentLanguage         string                       `json:"contentLanguage,omitempty"`
	WebsiteRedirectLocation string                       `json:"websiteRedirectLocation,omitempty"`
	RetentionMode           string                       `json:"retentionMode,omitempty"`
	StorageClass            string                       `json:"storageClass,omitempty"`
	ACL                     string                       `json:"acl,omitempty"`
	SSEKMSKeyID             string                       `json:"sseKMSKeyID,omitempty"`
	Parts                   []StoredObjectPart           `json:"parts,omitempty"`
	EncryptionNonce         []byte                       `json:"encryptionNonce,omitempty"`
	Data                    []byte                       `json:"data,omitempty"`
	StorageClassTransitions []StorageClassTransition     `json:"storageClassTransitions,omitempty"`
	EncryptionDEK           []byte                       `json:"encryptionDEK,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"`
	ChecksumCRC32     *string `json:"checksumCRC32,omitempty"`
	ChecksumCRC32C    *string `json:"checksumCRC32C,omitempty"`
	ChecksumCRC64NVME *string `json:"checksumCRC64NVME,omitempty"`
	ChecksumSHA1      *string `json:"checksumSHA1,omitempty"`
	ChecksumSHA256    *string `json:"checksumSHA256,omitempty"`
	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 TaggedEntry added in v1.3.1

type TaggedEntry struct {
	Tags map[string]string
	ARN  string
}

TaggedEntry pairs a bucket ARN with its tag set, for the Resource Groups Tagging API's GetResources (see cli.go's wireTaggingS3).

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
	// MfaDelete ("MfaDelete" element name confirmed s3@v1.106.5 deserializers.go's
	// awsRestxml_deserializeOpDocumentGetBucketVersioningOutput, case
	// strings.EqualFold("MfaDelete", ...)) is only present once a bucket has ever
	// had MFA delete configured -- omitted, not "Disabled", beforehand.
	MfaDelete string `xml:"MfaDelete,omitempty"`
}

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.

type ZstdCompressor

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

ZstdCompressor stores objects zstd-compressed and decodes both zstd and legacy gzip blobs, detected by magic bytes. The zero value is ready to use.

func (*ZstdCompressor) Compress

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

Compress zstd-encodes data unconditionally.

func (*ZstdCompressor) CompressForStore

func (c *ZstdCompressor) CompressForStore(parts [][]byte) ([]byte, bool, error)

CompressForStore returns the body to store and whether it is compressed. It stays raw when the data is incompressible or too large to decode safely.

func (*ZstdCompressor) CompressParts

func (c *ZstdCompressor) CompressParts(parts [][]byte) ([]byte, error)

CompressParts zstd-encodes the concatenation of parts without materialising it.

func (*ZstdCompressor) Decompress

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

Decompress decodes a zstd or gzip blob, chosen by magic bytes.

func (*ZstdCompressor) DecompressRange

func (c *ZstdCompressor) DecompressRange(data []byte, size, start, end int64) ([]byte, bool, error)

DecompressRange decodes only decoded bytes [start,end] of a seekable blob holding size bytes. ok is false when the blob has no valid index.

Source Files

Jump to

Keyboard shortcuts

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