Documentation
¶
Overview ¶
Package fs is a S3-compatible storage server implementation.
Index ¶
- Variables
- type Bucket
- type CompleteMultipartUploadRequest
- type CompleteMultipartUploadResponse
- type CompletedPart
- type CreateMultipartUploadRequest
- type GetObjectResponse
- type MultipartUpload
- type Object
- type ObjectMetadata
- type Part
- type PutObjectRequest
- type PutObjectResponse
- type Storage
- type Tag
- type UploadPartRequest
Constants ¶
This section is empty.
Variables ¶
var ( ErrBucketNotFound = errors.New("bucket not found") ErrBucketAlreadyExists = errors.New("bucket already exists") ErrBucketNotEmpty = errors.New("bucket not empty") ErrObjectNotFound = errors.New("object not found") ErrUploadNotFound = errors.New("upload not found") ErrInvalidBucketName = errors.New("invalid bucket name") ErrUnsupportedOperation = errors.New("unsupported operation") ErrPreconditionFailed = errors.New("precondition failed") // ErrInvalidPart reports that a part referenced by CompleteMultipartUpload // was never uploaded or its ETag does not match. ErrInvalidPart = errors.New("invalid part") // ErrInvalidPartOrder reports that the CompleteMultipartUpload part list is // not in strictly ascending part-number order. ErrInvalidPartOrder = errors.New("invalid part order") // ErrInvalidPartNumber reports a part number outside the valid 1..10000 range. ErrInvalidPartNumber = errors.New("invalid part number") // ErrEntityTooSmall reports a non-last multipart part smaller than the 5 MiB // minimum. ErrEntityTooSmall = errors.New("entity too small") // ErrInvalidTag reports an object tag set violating the S3 limits // (at most 10 tags, unique keys, key ≤ 128 chars, value ≤ 256 chars). ErrInvalidTag = errors.New("invalid tag") )
Functions ¶
This section is empty.
Types ¶
type CompleteMultipartUploadRequest ¶ added in v0.0.4
type CompleteMultipartUploadRequest struct {
Bucket string
Key string
UploadID string
Parts []CompletedPart
}
CompleteMultipartUploadRequest represents a request to complete multipart upload.
type CompleteMultipartUploadResponse ¶ added in v0.0.4
type CompleteMultipartUploadResponse struct {
Location string
Bucket string
Key string
ETag string
}
CompleteMultipartUploadResponse represents the response for completing multipart upload.
type CompletedPart ¶ added in v0.0.4
CompletedPart represents a completed part for completing multipart upload.
type CreateMultipartUploadRequest ¶ added in v0.4.0
type CreateMultipartUploadRequest struct {
Bucket string
Key string
Metadata ObjectMetadata
Tags []Tag
}
CreateMultipartUploadRequest represents a request to start a multipart upload. Metadata and tags are applied to the object at completion.
type GetObjectResponse ¶
type GetObjectResponse struct {
Reader io.ReadCloser
Size int64
LastModified time.Time
ETag string
Metadata ObjectMetadata
}
GetObjectResponse represents the response for GetObject operation.
type MultipartUpload ¶ added in v0.0.4
MultipartUpload represents an in-progress multipart upload.
type ObjectMetadata ¶ added in v0.4.0
type ObjectMetadata struct {
ContentType string
CacheControl string
ContentDisposition string
ContentEncoding string
// UserMetadata holds x-amz-meta-* pairs, keyed by the lowercase name
// without the prefix (e.g. "color" for x-amz-meta-color).
UserMetadata map[string]string
}
ObjectMetadata holds the user-controlled metadata stored with an object: the standard HTTP representation headers plus x-amz-meta-* pairs.
func (ObjectMetadata) IsZero ¶ added in v0.4.0
func (m ObjectMetadata) IsZero() bool
IsZero reports whether no metadata field is set.
type PutObjectRequest ¶
type PutObjectRequest struct {
Reader io.Reader
Bucket string
Key string
Size int64
Metadata ObjectMetadata
Tags []Tag
// IfNoneMatch and IfMatch carry the raw conditional-write header values
// (e.g. "*" or a quoted ETag list). When set, the storage backend must
// evaluate them atomically with the write — see PreconditionFailed — so
// concurrent conditional PUTs resolve to a single winner. Empty means no
// condition.
IfNoneMatch string
IfMatch string
}
func (*PutObjectRequest) PreconditionFailed ¶ added in v0.4.0
func (r *PutObjectRequest) PreconditionFailed(exists bool, currentETag string) bool
PreconditionFailed reports whether the request's If-None-Match / If-Match conditions fail against the current object state, where exists reports whether the target object is present and currentETag is its ETag (quoted or bare; only meaningful when exists is true). A true result means the write must be rejected with ErrPreconditionFailed.
Storage backends MUST call this while holding the lock that serializes writes to the key, so the evaluation is atomic with the write. Evaluating the condition in a separate step before the write (check-then-act) races: several concurrent If-None-Match: * writers can all observe "absent" and all succeed.
Semantics (matching S3):
- If-None-Match: * fail if the object exists.
- If-None-Match: "<etag>" fail if it exists and the ETag matches.
- If-Match: * fail if the object does not exist.
- If-Match: "<etag>" fail if it is missing or the ETag differs.
type PutObjectResponse ¶ added in v0.4.0
type PutObjectResponse struct {
ETag string
}
PutObjectResponse reports the stored object's ETag.
type Storage ¶
type Storage interface {
ListBuckets(ctx context.Context) ([]Bucket, error)
CreateBucket(ctx context.Context, bucket string) error
DeleteBucket(ctx context.Context, bucket string) error
BucketExists(ctx context.Context, bucket string) (bool, error)
ListObjects(ctx context.Context, bucket, prefix string) ([]Object, error)
PutObject(ctx context.Context, req *PutObjectRequest) (*PutObjectResponse, error)
GetObject(ctx context.Context, bucket, key string) (*GetObjectResponse, error)
DeleteObject(ctx context.Context, bucket, key string) error
// GetObjectTagging returns the object's tag set (empty when untagged).
GetObjectTagging(ctx context.Context, bucket, key string) ([]Tag, error)
// PutObjectTagging replaces the object's tag set.
PutObjectTagging(ctx context.Context, bucket, key string, tags []Tag) error
// DeleteObjectTagging removes the object's tag set.
DeleteObjectTagging(ctx context.Context, bucket, key string) error
CreateMultipartUpload(ctx context.Context, req *CreateMultipartUploadRequest) (*MultipartUpload, error)
UploadPart(ctx context.Context, req *UploadPartRequest) (*Part, error)
// ListParts returns the parts uploaded so far for an in-progress multipart
// upload, sorted by ascending part number.
ListParts(ctx context.Context, bucket, key, uploadID string) ([]Part, error)
// ListMultipartUploads returns the in-progress multipart uploads for a
// bucket, sorted by object key (then upload ID for equal keys).
ListMultipartUploads(ctx context.Context, bucket string) ([]MultipartUpload, error)
CompleteMultipartUpload(ctx context.Context, req *CompleteMultipartUploadRequest) (*CompleteMultipartUploadResponse, error)
AbortMultipartUpload(ctx context.Context, bucket, key, uploadID string) error
}
Storage defines the interface for S3-compatible storage operations.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
fs
command
|
|
|
internal
|
|
|
s3err
Package s3err renders S3-compatible error responses.
|
Package s3err renders S3-compatible error responses. |
|
scripts
|
|
|
gencompat
command
Command gencompat generates docs/CONFORMANCE.md from the ceph/s3-tests allow-list, grouping the passing tests by feature area.
|
Command gencompat generates docs/CONFORMANCE.md from the ceph/s3-tests allow-list, grouping the passing tests by feature area. |
|
Package server provides an embeddable S3-compatible HTTP server.
|
Package server provides an embeddable S3-compatible HTTP server. |
|
Package storagefs implements fs.Storage.
|
Package storagefs implements fs.Storage. |
|
Package storagemem implements fs.Storage using in-memory storage.
|
Package storagemem implements fs.Storage using in-memory storage. |
|
Package storagetest provides a conformance test suite for fs.Storage implementations.
|
Package storagetest provides a conformance test suite for fs.Storage implementations. |