backend

package
v1.50.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: BSD-2-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package backend proides the backends used by fake-gcs-server.

Index

Constants

View Source
const (
	BucketNotFound     = Error("bucket not found")
	BucketNotEmpty     = Error("bucket must be empty prior to deletion")
	PreConditionFailed = Error("Precondition failed")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket added in v1.16.0

type Bucket struct {
	Name                  string
	VersioningEnabled     bool
	TimeCreated           time.Time
	DefaultEventBasedHold bool
}

Bucket represents the bucket that is stored within the fake server.

type BucketAttrs added in v1.46.0

type BucketAttrs struct {
	DefaultEventBasedHold bool
	VersioningEnabled     bool
}

type Conditions added in v1.41.0

type Conditions interface {
	ConditionsMet(activeGeneration int64) bool
}

type Error added in v1.24.0

type Error string

func (Error) Error added in v1.24.0

func (e Error) Error() string

type NoConditions added in v1.41.0

type NoConditions struct{}

func (NoConditions) ConditionsMet added in v1.41.0

func (NoConditions) ConditionsMet(int64) bool

type Object

type Object struct {
	ObjectAttrs
	Content []byte
}

Object represents the object that is stored within the fake server.

func (Object) StreamingObject added in v1.40.0

func (o Object) StreamingObject() StreamingObject

type ObjectAttrs added in v1.30.0

type ObjectAttrs struct {
	BucketName         string `json:"-"`
	Name               string `json:"-"`
	Size               int64  `json:"-"`
	ContentType        string
	ContentEncoding    string
	ContentDisposition string
	CacheControl       string
	Crc32c             string
	Md5Hash            string
	Etag               string
	ACL                []storage.ACLRule
	Metadata           map[string]string
	Created            string
	Deleted            string
	Updated            string
	CustomTime         string
	Generation         int64
}

ObjectAttrs represents the meta-data without its contents.

func (*ObjectAttrs) ID added in v1.30.0

func (o *ObjectAttrs) ID() string

ID is used for comparing objects.

func (*ObjectAttrs) IDNoGen added in v1.30.0

func (o *ObjectAttrs) IDNoGen() string

IDNoGen does not consider the generation field.

type Storage

type Storage interface {
	CreateBucket(name string, bucketAttrs BucketAttrs) error
	ListBuckets() ([]Bucket, error)
	GetBucket(name string) (Bucket, error)
	UpdateBucket(name string, attrsToUpdate BucketAttrs) error
	DeleteBucket(name string) error
	CreateObject(obj StreamingObject, conditions Conditions) (StreamingObject, error)
	ListObjects(bucketName string, prefix string, versions bool) ([]ObjectAttrs, error)
	GetObject(bucketName, objectName string) (StreamingObject, error)
	GetObjectWithGeneration(bucketName, objectName string, generation int64) (StreamingObject, error)
	DeleteObject(bucketName, objectName string) error
	PatchObject(bucketName, objectName string, attrsToUpdate ObjectAttrs) (StreamingObject, error)
	UpdateObject(bucketName, objectName string, attrsToUpdate ObjectAttrs) (StreamingObject, error)
	ComposeObject(bucketName string, objectNames []string, destinationName string, metadata map[string]string, contentType string) (StreamingObject, error)
}

Storage is the generic interface for implementing the backend storage of the server.

func NewStorageFS

func NewStorageFS(objects []StreamingObject, rootDir string) (Storage, error)

NewStorageFS creates an instance of the filesystem-backed storage backend.

func NewStorageMemory

func NewStorageMemory(objects []StreamingObject) (Storage, error)

NewStorageMemory creates an instance of StorageMemory.

type StreamingObject added in v1.40.0

type StreamingObject struct {
	ObjectAttrs
	Content io.ReadSeekCloser
}

func (*StreamingObject) BufferedObject added in v1.40.0

func (o *StreamingObject) BufferedObject() (Object, error)

Convert this StreamingObject to a (buffered) Object.

func (*StreamingObject) Close added in v1.40.0

func (o *StreamingObject) Close() error

Jump to

Keyboard shortcuts

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