backend

package
v1.26.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Overview

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

Index

Constants

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

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
}

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

type Error added in v1.24.0

type Error string

func (Error) Error added in v1.24.0

func (e Error) Error() string

type Object

type Object struct {
	BucketName      string `json:"-"`
	Name            string `json:"-"`
	ContentType     string
	ContentEncoding string
	Content         []byte
	Crc32c          string
	Md5Hash         string
	ACL             []storage.ACLRule
	Metadata        map[string]string
	Created         string
	Deleted         string
	Updated         string
	Generation      int64
}

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

func (*Object) ID

func (o *Object) ID() string

ID is used for comparing objects.

func (*Object) IDNoGen added in v1.16.0

func (o *Object) IDNoGen() string

IDNoGen does not consider the generation field.

type Storage

type Storage interface {
	CreateBucket(name string, versioningEnabled bool) error
	ListBuckets() ([]Bucket, error)
	GetBucket(name string) (Bucket, error)
	DeleteBucket(name string) error
	CreateObject(obj Object) (Object, error)
	ListObjects(bucketName string, versions bool) ([]Object, error)
	GetObject(bucketName, objectName string) (Object, error)
	GetObjectWithGeneration(bucketName, objectName string, generation int64) (Object, error)
	DeleteObject(bucketName, objectName string) error
	PatchObject(bucketName, objectName string, metadata map[string]string) (Object, error)
}

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

func NewStorageFS

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

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

func NewStorageMemory

func NewStorageMemory(objects []Object) Storage

NewStorageMemory creates an instance of StorageMemory.

Jump to

Keyboard shortcuts

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