layer

package
v0.30.2 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AESEncryptionAlgorithm       = "AES256"
	AESKeySize                   = 32
	AttributeEncryptionAlgorithm = api.FrostFSSystemMetadataPrefix + "Algorithm"
	AttributeDecryptedSize       = api.FrostFSSystemMetadataPrefix + "Decrypted-Size"
	AttributeHMACSalt            = api.FrostFSSystemMetadataPrefix + "HMAC-Salt"
	AttributeHMACKey             = api.FrostFSSystemMetadataPrefix + "HMAC-Key"

	AttributeFrostfsCopiesNumber = "frostfs-copies-number" // such format to match X-Amz-Meta-Frostfs-Copies-Number header
)
View Source
const (
	UploadIDAttributeName         = "S3-Upload-Id"
	UploadPartNumberAttributeName = "S3-Upload-Part-Number"
	UploadCompletedParts          = "S3-Completed-Parts"

	// MultipartObjectSize contains the real object size if object is combined (payload contains list of parts).
	// This header is used to determine if object is combined.
	MultipartObjectSize = "S3-Multipart-Object-Size"

	MaxSizeUploadsList  = 1000
	MaxSizePartsList    = 1000
	UploadMinPartNumber = 1
	UploadMaxPartNumber = 10000
	UploadMinSize       = 5 * 1024 * 1024      // 5MB
	UploadMaxSize       = 1024 * UploadMinSize // 5GB
)
View Source
const (
	AttributeComplianceMode = ".s3-compliance-mode"
)
View Source
const (
	AttributeLockEnabled = "LockEnabled"
)
View Source
const PathSeparator = string(os.PathSeparator)

PathSeparator is a path components separator string.

Variables

View Source
var (
	// ErrAccessDenied is returned from FrostFS in case of access violation.
	ErrAccessDenied = errors.New("access denied")

	// ErrGatewayTimeout is returned from FrostFS in case of timeout, deadline exceeded etc.
	ErrGatewayTimeout = errors.New("gateway timeout")
)
View Source
var (
	// ErrNodeNotFound is returned from Tree service in case of not found error.
	ErrNodeNotFound = errors.New("not found")

	// ErrNodeAccessDenied is returned from Tree service in case of access denied error.
	ErrNodeAccessDenied = errors.New("access denied")

	// ErrNoNodeToRemove is returned from Tree service in case of the lack of node with OID to remove.
	ErrNoNodeToRemove = errors.New("no node to remove")
)
View Source
var EncryptionMetadata = map[string]struct{}{
	AttributeEncryptionAlgorithm: {},
	AttributeDecryptedSize:       {},
	AttributeHMACSalt:            {},
	AttributeHMACKey:             {},
}

Functions

func FormEncryptionInfo

func FormEncryptionInfo(headers map[string]string) encryption.ObjectEncryption

func GetObjectSize added in v0.28.0

func GetObjectSize(objInfo *data.ObjectInfo) (uint64, error)

func IsAuthenticatedRequest

func IsAuthenticatedRequest(ctx context.Context) bool

IsAuthenticatedRequest checks if access box exists in the current request.

func IsSystemHeader

func IsSystemHeader(key string) bool

func MimeByFilePath

func MimeByFilePath(path string) string

MimeByFilePath detect mime type by file path extension.

func NameFromString

func NameFromString(name string) (string, string)

NameFromString splits name into a base file name and a directory path.

func TimeNow

func TimeNow(ctx context.Context) time.Time

TimeNow returns client time from request or time.Now().

Types

type AnonymousKey

type AnonymousKey struct {
	Key *keys.PrivateKey
}

AnonymousKey contains data for anonymous requests.

type BucketResolver

type BucketResolver interface {
	Resolve(ctx context.Context, name string) (cid.ID, error)
}

type Cache

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

func NewCache

func NewCache(cfg *CachesConfig) *Cache

func (*Cache) CleanListCacheEntriesContainingObject

func (c *Cache) CleanListCacheEntriesContainingObject(objectName string, cnrID cid.ID)

func (*Cache) DeleteBucket

func (c *Cache) DeleteBucket(bktInfo *data.BucketInfo)

func (*Cache) DeleteCORS

func (c *Cache) DeleteCORS(bktInfo *data.BucketInfo)

func (*Cache) DeleteListSession added in v0.29.0

func (c *Cache) DeleteListSession(owner user.ID, key cache.ListSessionKey)

func (*Cache) DeleteObject

func (c *Cache) DeleteObject(addr oid.Address)

func (*Cache) DeleteObjectName

func (c *Cache) DeleteObjectName(cnrID cid.ID, bktName, objName string)

func (*Cache) DeleteTagging

func (c *Cache) DeleteTagging(key string)

func (*Cache) GetBucket

func (c *Cache) GetBucket(zone, name string) *data.BucketInfo

func (*Cache) GetCORS

func (c *Cache) GetCORS(owner user.ID, bkt *data.BucketInfo) *data.CORSConfiguration

func (*Cache) GetLastObject

func (c *Cache) GetLastObject(owner user.ID, bktName, objName string) *data.ExtendedObjectInfo

func (*Cache) GetList

func (c *Cache) GetList(owner user.ID, key cache.ObjectsListKey) []*data.NodeVersion

func (*Cache) GetListSession added in v0.29.0

func (c *Cache) GetListSession(owner user.ID, key cache.ListSessionKey) *data.ListSession

func (*Cache) GetLockInfo

func (c *Cache) GetLockInfo(owner user.ID, key string) *data.LockInfo

func (*Cache) GetObject

func (c *Cache) GetObject(owner user.ID, addr oid.Address) *data.ExtendedObjectInfo

func (*Cache) GetSettings

func (c *Cache) GetSettings(owner user.ID, bktInfo *data.BucketInfo) *data.BucketSettings

func (*Cache) GetTagging

func (c *Cache) GetTagging(owner user.ID, key string) map[string]string

func (*Cache) PutBucket

func (c *Cache) PutBucket(bktInfo *data.BucketInfo)

func (*Cache) PutCORS

func (c *Cache) PutCORS(owner user.ID, bkt *data.BucketInfo, cors *data.CORSConfiguration)

func (*Cache) PutList

func (c *Cache) PutList(owner user.ID, key cache.ObjectsListKey, list []*data.NodeVersion)

func (*Cache) PutListSession added in v0.29.0

func (c *Cache) PutListSession(owner user.ID, key cache.ListSessionKey, session *data.ListSession)

func (*Cache) PutLockInfo

func (c *Cache) PutLockInfo(owner user.ID, key string, lockInfo *data.LockInfo)

func (*Cache) PutObject

func (c *Cache) PutObject(owner user.ID, extObjInfo *data.ExtendedObjectInfo)

func (*Cache) PutObjectWithName

func (c *Cache) PutObjectWithName(owner user.ID, extObjInfo *data.ExtendedObjectInfo)

func (*Cache) PutSettings

func (c *Cache) PutSettings(owner user.ID, bktInfo *data.BucketInfo, settings *data.BucketSettings)

func (*Cache) PutTagging

func (c *Cache) PutTagging(owner user.ID, key string, tags map[string]string)

type CachesConfig

type CachesConfig struct {
	Logger        *zap.Logger
	Objects       *cache.Config
	ObjectsList   *cache.Config
	SessionList   *cache.Config
	Names         *cache.Config
	Buckets       *cache.Config
	System        *cache.Config
	AccessControl *cache.Config
}

CachesConfig contains params for caches.

func DefaultCachesConfigs

func DefaultCachesConfigs(logger *zap.Logger) *CachesConfig

DefaultCachesConfigs returns filled configs.

type CompleteMultipartParams

type CompleteMultipartParams struct {
	Info  *UploadInfoParams
	Parts []*CompletedPart
}

type CompletedPart

type CompletedPart struct {
	ETag       string
	PartNumber int
}

type Config

type Config struct {
	GateOwner    user.ID
	ChainAddress string
	Cache        *Cache
	AnonKey      AnonymousKey
	Resolver     BucketResolver
	TreeService  TreeService
	Features     FeatureSettings
}

type ContainerCreateResult added in v0.29.0

type ContainerCreateResult struct {
	ContainerID             cid.ID
	HomomorphicHashDisabled bool
}

ContainerCreateResult is a result parameter of FrostFS.CreateContainer operation.

type CopyObjectParams

type CopyObjectParams struct {
	SrcVersioned  bool
	SrcObject     *data.ObjectInfo
	ScrBktInfo    *data.BucketInfo
	DstBktInfo    *data.BucketInfo
	DstObject     string
	DstSize       uint64
	Header        map[string]string
	Range         *RangeParams
	Lock          *data.ObjectLock
	SrcEncryption encryption.Params
	DstEncryption encryption.Params
	CopiesNumbers []uint32
}

CopyObjectParams stores object copy request parameters.

type CreateBucketParams

type CreateBucketParams struct {
	Name                     string
	Namespace                string
	Policy                   netmap.PlacementPolicy
	SessionContainerCreation *session.Container
	LocationConstraint       string
	ObjectLockEnabled        bool
}

CreateBucketParams stores bucket create request parameters.

type CreateMultipartParams

type CreateMultipartParams struct {
	Info          *UploadInfoParams
	Header        map[string]string
	Data          *UploadData
	CopiesNumbers []uint32
}

type DeleteBucketParams

type DeleteBucketParams struct {
	BktInfo      *data.BucketInfo
	SessionToken *session.Container
}

DeleteBucketParams stores delete bucket request parameters.

type DeleteMarkerError added in v0.29.0

type DeleteMarkerError struct {
	ErrorCode apiErrors.ErrorCode
}

func (DeleteMarkerError) Error added in v0.29.0

func (e DeleteMarkerError) Error() string

type DeleteObjectParams

type DeleteObjectParams struct {
	BktInfo    *data.BucketInfo
	Objects    []*VersionedObject
	Settings   *data.BucketSettings
	IsMultiple bool
}

type EncryptedPart

type EncryptedPart struct {
	Part
	EncryptedSize int64
}

type FeatureSettings added in v0.28.0

type FeatureSettings interface {
	ClientCut() bool
	BufferMaxSizeForPut() uint64
	MD5Enabled() bool
	FormContainerZone(ns string) (zone string, isDefault bool)
}

type FeatureSettingsMock added in v0.28.0

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

func (*FeatureSettingsMock) BufferMaxSizeForPut added in v0.29.0

func (k *FeatureSettingsMock) BufferMaxSizeForPut() uint64

func (*FeatureSettingsMock) ClientCut added in v0.28.0

func (k *FeatureSettingsMock) ClientCut() bool

func (*FeatureSettingsMock) FormContainerZone added in v0.29.0

func (k *FeatureSettingsMock) FormContainerZone(ns string) (zone string, isDefault bool)

func (*FeatureSettingsMock) MD5Enabled added in v0.28.1

func (k *FeatureSettingsMock) MD5Enabled() bool

func (*FeatureSettingsMock) SetClientCut added in v0.28.0

func (k *FeatureSettingsMock) SetClientCut(clientCut bool)

func (*FeatureSettingsMock) SetMD5Enabled added in v0.28.1

func (k *FeatureSettingsMock) SetMD5Enabled(md5Enabled bool)

type FrostFS

type FrostFS interface {
	// CreateContainer creates and saves parameterized container in FrostFS.
	// It sets 'Timestamp' attribute to the current time.
	// It returns the ID of the saved container.
	//
	// It returns exactly one non-zero value. It returns any error encountered which
	// prevented the container from being created.
	CreateContainer(context.Context, PrmContainerCreate) (*ContainerCreateResult, error)

	// Container reads a container from FrostFS by ID.
	//
	// It returns exactly one non-nil value. It returns any error encountered which
	// prevented the container from being read.
	Container(context.Context, PrmContainer) (*container.Container, error)

	// UserContainers reads a list of the containers owned by the specified user.
	//
	// It returns exactly one non-nil value. It returns any error encountered which
	// prevented the containers from being listed.
	UserContainers(context.Context, PrmUserContainers) ([]cid.ID, error)

	// DeleteContainer marks the container to be removed from FrostFS by ID.
	// Request is sent within session if the session token is specified.
	// Successful return does not guarantee actual removal.
	//
	// It returns any error encountered which prevented the removal request from being sent.
	DeleteContainer(context.Context, cid.ID, *session.Container) error

	// ReadObject reads a part of the object from the FrostFS container by identifier.
	// Exact part is returned according to the parameters:
	//   * with header only: empty payload (both in-mem and reader parts are nil);
	//   * with payload only: header is nil (zero range means full payload);
	//   * with header and payload: full in-mem object, payload reader is nil.
	//
	// WithHeader or WithPayload is true. Range length is positive if offset is positive.
	//
	// Payload reader should be closed if it is no longer needed.
	//
	// It returns ErrAccessDenied on read access violation.
	//
	// It returns exactly one non-nil value. It returns any error encountered which
	// prevented the object header from being read.
	ReadObject(context.Context, PrmObjectRead) (*ObjectPart, error)

	// CreateObject creates and saves a parameterized object in the FrostFS container.
	// It sets 'Timestamp' attribute to the current time.
	// It returns the ID of the saved object.
	//
	// Creation time should be written into the object (UTC).
	//
	// It returns ErrAccessDenied on write access violation.
	//
	// It returns exactly one non-zero value. It returns any error encountered which
	// prevented the container from being created.
	CreateObject(context.Context, PrmObjectCreate) (oid.ID, error)

	// DeleteObject marks the object to be removed from the FrostFS container by identifier.
	// Successful return does not guarantee actual removal.
	//
	// It returns ErrAccessDenied on remove access violation.
	//
	// It returns any error encountered which prevented the removal request from being sent.
	DeleteObject(context.Context, PrmObjectDelete) error

	// SearchObjects performs object search from the NeoFS container according
	// to the specified parameters. It searches user's objects only.
	//
	// It returns ErrAccessDenied on selection access violation.
	//
	// It returns exactly one non-nil value. It returns any error encountered which
	// prevented the objects from being selected.
	SearchObjects(context.Context, PrmObjectSearch) ([]oid.ID, error)

	// TimeToEpoch computes current epoch and the epoch that corresponds to the provided now and future time.
	// Note:
	// * future time must be after the now
	// * future time will be ceil rounded to match epoch
	//
	// It returns any error encountered which prevented computing epochs.
	TimeToEpoch(ctx context.Context, now time.Time, future time.Time) (uint64, uint64, error)
}

FrostFS represents virtual connection to FrostFS network.

type GetObjectParams

type GetObjectParams struct {
	Range      *RangeParams
	ObjectInfo *data.ObjectInfo
	BucketInfo *data.BucketInfo
	Versioned  bool
	Encryption encryption.Params
}

GetObjectParams stores object get request parameters.

type HeadObjectParams

type HeadObjectParams struct {
	BktInfo   *data.BucketInfo
	Object    string
	VersionID string
}

HeadObjectParams stores object head request parameters.

func (HeadObjectParams) Versioned added in v0.28.0

func (p HeadObjectParams) Versioned() bool

type Layer added in v0.30.0

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

func NewLayer

func NewLayer(log *zap.Logger, frostFS FrostFS, config *Config) *Layer

NewLayer creates an instance of a Layer. It checks credentials and establishes gRPC connection with the node.

func (*Layer) AbortMultipartUpload added in v0.30.0

func (n *Layer) AbortMultipartUpload(ctx context.Context, p *UploadInfoParams) error

func (*Layer) BearerOwner added in v0.30.0

func (n *Layer) BearerOwner(ctx context.Context) user.ID

BearerOwner returns owner id from BearerToken (context) or from client owner.

func (*Layer) CompleteMultipartUpload added in v0.30.0

func (n *Layer) CompleteMultipartUpload(ctx context.Context, p *CompleteMultipartParams) (*UploadData, *data.ExtendedObjectInfo, error)

func (*Layer) CopyObject added in v0.30.0

func (n *Layer) CopyObject(ctx context.Context, p *CopyObjectParams) (*data.ExtendedObjectInfo, error)

CopyObject from one bucket into another bucket.

func (*Layer) CreateBucket added in v0.30.0

func (n *Layer) CreateBucket(ctx context.Context, p *CreateBucketParams) (*data.BucketInfo, error)

func (*Layer) CreateMultipartUpload added in v0.30.0

func (n *Layer) CreateMultipartUpload(ctx context.Context, p *CreateMultipartParams) error

func (*Layer) DeleteBucket added in v0.30.0

func (n *Layer) DeleteBucket(ctx context.Context, p *DeleteBucketParams) error

func (*Layer) DeleteBucketCORS added in v0.30.0

func (n *Layer) DeleteBucketCORS(ctx context.Context, bktInfo *data.BucketInfo) error

func (*Layer) DeleteBucketTagging added in v0.30.0

func (n *Layer) DeleteBucketTagging(ctx context.Context, bktInfo *data.BucketInfo) error

func (*Layer) DeleteObjectTagging added in v0.30.0

func (n *Layer) DeleteObjectTagging(ctx context.Context, p *data.ObjectVersion) error

func (*Layer) DeleteObjects added in v0.30.0

func (n *Layer) DeleteObjects(ctx context.Context, p *DeleteObjectParams) []*VersionedObject

DeleteObjects from the storage.

func (*Layer) EphemeralKey added in v0.30.0

func (n *Layer) EphemeralKey() *keys.PublicKey

func (*Layer) GetBucketCORS added in v0.30.0

func (n *Layer) GetBucketCORS(ctx context.Context, bktInfo *data.BucketInfo) (*data.CORSConfiguration, error)

func (*Layer) GetBucketInfo added in v0.30.0

func (n *Layer) GetBucketInfo(ctx context.Context, name string) (*data.BucketInfo, error)

GetBucketInfo returns bucket info by name.

func (*Layer) GetBucketSettings added in v0.30.0

func (n *Layer) GetBucketSettings(ctx context.Context, bktInfo *data.BucketInfo) (*data.BucketSettings, error)

func (*Layer) GetBucketTagging added in v0.30.0

func (n *Layer) GetBucketTagging(ctx context.Context, bktInfo *data.BucketInfo) (map[string]string, error)

func (*Layer) GetExtendedObjectInfo added in v0.30.0

func (n *Layer) GetExtendedObjectInfo(ctx context.Context, p *HeadObjectParams) (*data.ExtendedObjectInfo, error)

GetExtendedObjectInfo returns meta information and corresponding info from the tree service about the object.

func (*Layer) GetLockInfo added in v0.30.0

func (n *Layer) GetLockInfo(ctx context.Context, objVersion *data.ObjectVersion) (*data.LockInfo, error)

func (*Layer) GetObject added in v0.30.0

func (n *Layer) GetObject(ctx context.Context, p *GetObjectParams) (*ObjectPayload, error)

GetObject from storage.

func (*Layer) GetObjectInfo added in v0.30.0

func (n *Layer) GetObjectInfo(ctx context.Context, p *HeadObjectParams) (*data.ObjectInfo, error)

GetObjectInfo returns meta information about the object.

func (*Layer) GetObjectTagging added in v0.30.0

func (n *Layer) GetObjectTagging(ctx context.Context, p *data.GetObjectTaggingParams) (string, map[string]string, error)

func (*Layer) GetObjectTaggingAndLock added in v0.30.0

func (n *Layer) GetObjectTaggingAndLock(ctx context.Context, objVersion *data.ObjectVersion, nodeVersion *data.NodeVersion) (map[string]string, data.LockInfo, error)

func (*Layer) ListBuckets added in v0.30.0

func (n *Layer) ListBuckets(ctx context.Context) ([]*data.BucketInfo, error)

ListBuckets returns all user containers. The name of the bucket is a container id. Timestamp is omitted since it is not saved in frostfs container.

func (*Layer) ListMultipartUploads added in v0.30.0

func (n *Layer) ListMultipartUploads(ctx context.Context, p *ListMultipartUploadsParams) (*ListMultipartUploadsInfo, error)

func (*Layer) ListObjectVersions added in v0.30.0

func (n *Layer) ListObjectVersions(ctx context.Context, p *ListObjectVersionsParams) (*ListObjectVersionsInfo, error)

func (*Layer) ListObjectsV1 added in v0.30.0

func (n *Layer) ListObjectsV1(ctx context.Context, p *ListObjectsParamsV1) (*ListObjectsInfoV1, error)

ListObjectsV1 returns objects in a bucket for requests of Version 1.

func (*Layer) ListObjectsV2 added in v0.30.0

func (n *Layer) ListObjectsV2(ctx context.Context, p *ListObjectsParamsV2) (*ListObjectsInfoV2, error)

ListObjectsV2 returns objects in a bucket for requests of Version 2.

func (*Layer) ListParts added in v0.30.0

func (n *Layer) ListParts(ctx context.Context, p *ListPartsParams) (*ListPartsInfo, error)

func (*Layer) PutBucketCORS added in v0.30.0

func (n *Layer) PutBucketCORS(ctx context.Context, p *PutCORSParams) error

func (*Layer) PutBucketSettings added in v0.30.0

func (n *Layer) PutBucketSettings(ctx context.Context, p *PutSettingsParams) error

func (*Layer) PutBucketTagging added in v0.30.0

func (n *Layer) PutBucketTagging(ctx context.Context, bktInfo *data.BucketInfo, tagSet map[string]string) error

func (*Layer) PutLockInfo added in v0.30.0

func (n *Layer) PutLockInfo(ctx context.Context, p *PutLockInfoParams) (err error)

func (*Layer) PutObject added in v0.30.0

func (n *Layer) PutObject(ctx context.Context, p *PutObjectParams) (*data.ExtendedObjectInfo, error)

PutObject stores object into FrostFS, took payload from io.Reader.

func (*Layer) PutObjectTagging added in v0.30.0

func (n *Layer) PutObjectTagging(ctx context.Context, p *data.PutObjectTaggingParams) (err error)

func (*Layer) ResolveBucket added in v0.30.0

func (n *Layer) ResolveBucket(ctx context.Context, name string) (cid.ID, error)

func (*Layer) ResolveCID added in v0.30.0

func (n *Layer) ResolveCID(ctx context.Context, name string) (cid.ID, error)

ResolveCID returns container id by name.

func (*Layer) SessionTokenForRead added in v0.30.0

func (n *Layer) SessionTokenForRead(ctx context.Context) *session.Container

SessionTokenForRead returns session container token.

func (*Layer) UploadPart added in v0.30.0

func (n *Layer) UploadPart(ctx context.Context, p *UploadPartParams) (string, error)

func (*Layer) UploadPartCopy added in v0.30.0

func (n *Layer) UploadPartCopy(ctx context.Context, p *UploadCopyParams) (*data.ObjectInfo, error)

type ListMultipartUploadsInfo

type ListMultipartUploadsInfo struct {
	Prefixes           []string
	Uploads            []*UploadInfo
	IsTruncated        bool
	NextKeyMarker      string
	NextUploadIDMarker string
}

type ListMultipartUploadsParams

type ListMultipartUploadsParams struct {
	Bkt            *data.BucketInfo
	Delimiter      string
	EncodingType   string
	KeyMarker      string
	MaxUploads     int
	Prefix         string
	UploadIDMarker string
}

type ListObjectVersionsInfo

type ListObjectVersionsInfo struct {
	CommonPrefixes      []string
	IsTruncated         bool
	KeyMarker           string
	NextKeyMarker       string
	NextVersionIDMarker string
	Version             []*data.ExtendedNodeVersion
	DeleteMarker        []*data.ExtendedNodeVersion
	VersionIDMarker     string
}

ListObjectVersionsInfo stores info and list of objects versions.

type ListObjectVersionsParams

type ListObjectVersionsParams struct {
	BktInfo         *data.BucketInfo
	Delimiter       string
	KeyMarker       string
	MaxKeys         int
	Prefix          string
	VersionIDMarker string
	Encode          string
}

ListObjectVersionsParams stores list objects versions parameters.

type ListObjectsInfo

type ListObjectsInfo struct {
	Prefixes    []string
	Objects     []*data.ExtendedNodeVersion
	IsTruncated bool
}

ListObjectsInfo contains common fields of data for ListObjectsV1 and ListObjectsV2.

type ListObjectsInfoV1

type ListObjectsInfoV1 struct {
	ListObjectsInfo
	NextMarker string
}

ListObjectsInfoV1 holds data which ListObjectsV1 returns.

type ListObjectsInfoV2

type ListObjectsInfoV2 struct {
	ListObjectsInfo
	NextContinuationToken string
}

ListObjectsInfoV2 holds data which ListObjectsV2 returns.

type ListObjectsParamsCommon

type ListObjectsParamsCommon struct {
	BktInfo   *data.BucketInfo
	Delimiter string
	Encode    string
	MaxKeys   int
	Prefix    string
}

ListObjectsParamsCommon contains common parameters for ListObjectsV1 and ListObjectsV2.

type ListObjectsParamsV1

type ListObjectsParamsV1 struct {
	ListObjectsParamsCommon
	Marker string
}

ListObjectsParamsV1 contains params for ListObjectsV1.

type ListObjectsParamsV2

type ListObjectsParamsV2 struct {
	ListObjectsParamsCommon
	ContinuationToken string
	StartAfter        string
	FetchOwner        bool
}

ListObjectsParamsV2 contains params for ListObjectsV2.

type ListPartsInfo

type ListPartsInfo struct {
	Parts                []*Part
	Owner                user.ID
	NextPartNumberMarker int
	IsTruncated          bool
}

type ListPartsParams

type ListPartsParams struct {
	Info             *UploadInfoParams
	MaxParts         int
	PartNumberMarker int
}

type ListType added in v0.29.0

type ListType int
const (
	ListObjectsV1Type ListType = iota + 1
	ListObjectsV2Type ListType = iota + 1
)

type ObjectPart

type ObjectPart struct {
	// Object header with optional in-memory payload part.
	Head *object.Object

	// Object payload part encapsulated in io.Reader primitive.
	// Returns ErrAccessDenied on read access violation.
	Payload io.ReadCloser
}

ObjectPart represents partially read FrostFS object.

type ObjectPayload added in v0.28.0

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

func (*ObjectPayload) Read added in v0.28.0

func (o *ObjectPayload) Read(p []byte) (int, error)

Read implements io.Reader. If you want to use ObjectPayload as io.Reader you must not use ObjectPayload.StreamTo method and vice versa.

func (*ObjectPayload) StreamTo added in v0.28.0

func (o *ObjectPayload) StreamTo(w io.Writer) error

StreamTo reads all payload to provided writer. If you want to use this method you must not use ObjectPayload.Read and vice versa.

type Part

type Part struct {
	ETag         string
	LastModified string
	PartNumber   int
	Size         uint64
}

func ParseCompletedPartHeader

func ParseCompletedPartHeader(hdr string) (*Part, error)

type PrmAuth

type PrmAuth struct {
	// Bearer token to be used for the operation. Overlaps PrivateKey. Optional.
	BearerToken *bearer.Token

	// Private key used for the operation if BearerToken is missing (in this case non-nil).
	PrivateKey *ecdsa.PrivateKey
}

PrmAuth groups authentication parameters for the FrostFS operation.

type PrmContainer added in v0.29.0

type PrmContainer struct {
	// Container identifier.
	ContainerID cid.ID

	// Token of the container's creation session. Nil means session absence.
	SessionToken *session.Container
}

PrmContainer groups parameters of FrostFS.Container operation.

type PrmContainerCreate

type PrmContainerCreate struct {
	// FrostFS identifier of the container creator.
	Creator user.ID

	// Container placement policy.
	Policy netmap.PlacementPolicy

	// Name for the container.
	Name string

	// Zone for container registration.
	Zone string

	// CreationTime value for Timestamp attribute
	CreationTime time.Time

	// Token of the container's creation session. Nil means session absence.
	SessionToken *session.Container

	// Basic ACL of the container.
	BasicACL acl.Basic

	// Attributes for optional parameters.
	AdditionalAttributes [][2]string
}

PrmContainerCreate groups parameters of FrostFS.CreateContainer operation.

type PrmObjectCreate

type PrmObjectCreate struct {
	// Authentication parameters.
	PrmAuth

	// Container to store the object.
	Container cid.ID

	// Key-value object attributes.
	Attributes [][2]string

	// Value for Timestamp attribute (optional).
	CreationTime time.Time

	// List of ids to lock (optional).
	Locks []oid.ID

	// Full payload size (optional).
	PayloadSize uint64

	// Associated filepath (optional).
	Filepath string

	// Object payload encapsulated in io.Reader primitive.
	Payload io.Reader

	// Number of object copies that is enough to consider put successful.
	CopiesNumber []uint32

	// Enables client side object preparing.
	ClientCut bool

	// Disables using Tillich-Zémor hash for payload.
	WithoutHomomorphicHash bool

	// Sets max buffer size to read payload.
	BufferMaxSize uint64
}

PrmObjectCreate groups parameters of FrostFS.CreateObject operation.

type PrmObjectDelete

type PrmObjectDelete struct {
	// Authentication parameters.
	PrmAuth

	// Container to delete the object from.
	Container cid.ID

	// Identifier of the removed object.
	Object oid.ID
}

PrmObjectDelete groups parameters of FrostFS.DeleteObject operation.

type PrmObjectRead

type PrmObjectRead struct {
	// Authentication parameters.
	PrmAuth

	// Container to read the object header from.
	Container cid.ID

	// ID of the object for which to read the header.
	Object oid.ID

	// Flag to read object header.
	WithHeader bool

	// Flag to read object payload. False overlaps payload range.
	WithPayload bool

	// Offset-length range of the object payload to be read.
	PayloadRange [2]uint64
}

PrmObjectRead groups parameters of FrostFS.ReadObject operation.

type PrmObjectSearch added in v0.28.0

type PrmObjectSearch struct {
	// Authentication parameters.
	PrmAuth

	// Container to select the objects from.
	Container cid.ID

	// Key-value object attribute which should be
	// presented in selected objects. Optional, empty key means any.
	ExactAttribute [2]string

	// File prefix of the selected objects. Optional, empty value means any.
	FilePrefix string
}

PrmObjectSearch groups parameters of FrostFS.sear SearchObjects operation.

type PrmUserContainers added in v0.29.0

type PrmUserContainers struct {
	// User identifier.
	UserID user.ID

	// Token of the container's creation session. Nil means session absence.
	SessionToken *session.Container
}

PrmUserContainers groups parameters of FrostFS.UserContainers operation.

type PutCORSParams

type PutCORSParams struct {
	BktInfo       *data.BucketInfo
	Reader        io.Reader
	CopiesNumbers []uint32
	NewDecoder    func(io.Reader) *xml.Decoder
}

PutCORSParams stores PutCORS request parameters.

type PutCombinedObjectParams added in v0.28.0

type PutCombinedObjectParams struct {
	BktInfo    *data.BucketInfo
	Object     string
	Size       uint64
	Header     map[string]string
	Lock       *data.ObjectLock
	Encryption encryption.Params
}

type PutLockInfoParams

type PutLockInfoParams struct {
	ObjVersion    *data.ObjectVersion
	NewLock       *data.ObjectLock
	CopiesNumbers []uint32
	NodeVersion   *data.NodeVersion // optional
}

type PutObjectParams

type PutObjectParams struct {
	BktInfo           *data.BucketInfo
	Object            string
	Size              uint64
	Reader            io.Reader
	Header            map[string]string
	Lock              *data.ObjectLock
	Encryption        encryption.Params
	CopiesNumbers     []uint32
	CompleteMD5Hash   string
	ContentMD5        string
	ContentSHA256Hash string
}

PutObjectParams stores object put request parameters.

type PutSettingsParams

type PutSettingsParams struct {
	BktInfo  *data.BucketInfo
	Settings *data.BucketSettings
}

PutSettingsParams stores object copy request parameters.

type RangeParams

type RangeParams struct {
	Start uint64
	End   uint64
}

RangeParams stores range header request parameters.

type TestFrostFS

type TestFrostFS struct {
	FrostFS
	// contains filtered or unexported fields
}

func NewTestFrostFS

func NewTestFrostFS(key *keys.PrivateKey) *TestFrostFS

func (*TestFrostFS) AddObject

func (t *TestFrostFS) AddObject(key string, obj *object.Object)

func (*TestFrostFS) AllObjects

func (t *TestFrostFS) AllObjects(cnrID cid.ID) []oid.ID

func (*TestFrostFS) Container

func (t *TestFrostFS) Container(_ context.Context, prm PrmContainer) (*container.Container, error)

func (*TestFrostFS) ContainerID

func (t *TestFrostFS) ContainerID(name string) (cid.ID, error)

func (*TestFrostFS) CreateContainer

func (*TestFrostFS) CreateObject

func (t *TestFrostFS) CreateObject(_ context.Context, prm PrmObjectCreate) (oid.ID, error)

func (*TestFrostFS) CurrentEpoch

func (t *TestFrostFS) CurrentEpoch() uint64

func (*TestFrostFS) DeleteContainer

func (t *TestFrostFS) DeleteContainer(_ context.Context, cnrID cid.ID, _ *session.Container) error

func (*TestFrostFS) DeleteObject

func (t *TestFrostFS) DeleteObject(ctx context.Context, prm PrmObjectDelete) error

func (*TestFrostFS) ObjectExists

func (t *TestFrostFS) ObjectExists(objID oid.ID) bool

func (*TestFrostFS) Objects

func (t *TestFrostFS) Objects() []*object.Object

func (*TestFrostFS) ReadObject

func (t *TestFrostFS) ReadObject(ctx context.Context, prm PrmObjectRead) (*ObjectPart, error)

func (*TestFrostFS) SearchObjects added in v0.30.0

func (t *TestFrostFS) SearchObjects(_ context.Context, prm PrmObjectSearch) ([]oid.ID, error)

func (*TestFrostFS) SetContainer added in v0.29.0

func (t *TestFrostFS) SetContainer(cnrID cid.ID, cnr *container.Container)

func (*TestFrostFS) SetObjectError added in v0.28.0

func (t *TestFrostFS) SetObjectError(addr oid.Address, err error)

func (*TestFrostFS) SetObjectPutError added in v0.28.0

func (t *TestFrostFS) SetObjectPutError(fileName string, err error)

func (*TestFrostFS) TimeToEpoch

func (t *TestFrostFS) TimeToEpoch(_ context.Context, now, futureTime time.Time) (uint64, uint64, error)

func (*TestFrostFS) UserContainers

func (t *TestFrostFS) UserContainers(context.Context, PrmUserContainers) ([]cid.ID, error)

type TreeService

type TreeService interface {
	// PutSettingsNode update or create new settings node in tree service.
	PutSettingsNode(ctx context.Context, bktInfo *data.BucketInfo, settings *data.BucketSettings) error

	// GetSettingsNode retrieves the settings node from the tree service and form data.BucketSettings.
	//
	// If tree node is not found returns ErrNodeNotFound error.
	GetSettingsNode(ctx context.Context, bktInfo *data.BucketInfo) (*data.BucketSettings, error)

	// GetBucketCORS gets an object id that corresponds to object with bucket CORS.
	//
	// If object id is not found returns ErrNodeNotFound error.
	GetBucketCORS(ctx context.Context, bktInfo *data.BucketInfo) (oid.ID, error)

	// PutBucketCORS puts a node to a system tree and returns objectID of a previous cors config which must be deleted in FrostFS.
	//
	// If object ids to remove is not found returns ErrNoNodeToRemove error.
	PutBucketCORS(ctx context.Context, bktInfo *data.BucketInfo, objID oid.ID) ([]oid.ID, error)

	// DeleteBucketCORS removes a node from a system tree and returns objID which must be deleted in FrostFS.
	//
	// If object ids to remove is not found returns ErrNoNodeToRemove error.
	DeleteBucketCORS(ctx context.Context, bktInfo *data.BucketInfo) ([]oid.ID, error)

	GetObjectTagging(ctx context.Context, bktInfo *data.BucketInfo, objVersion *data.NodeVersion) (map[string]string, error)
	PutObjectTagging(ctx context.Context, bktInfo *data.BucketInfo, objVersion *data.NodeVersion, tagSet map[string]string) error
	DeleteObjectTagging(ctx context.Context, bktInfo *data.BucketInfo, objVersion *data.NodeVersion) error

	GetBucketTagging(ctx context.Context, bktInfo *data.BucketInfo) (map[string]string, error)
	PutBucketTagging(ctx context.Context, bktInfo *data.BucketInfo, tagSet map[string]string) error
	DeleteBucketTagging(ctx context.Context, bktInfo *data.BucketInfo) error

	GetVersions(ctx context.Context, bktInfo *data.BucketInfo, objectName string) ([]*data.NodeVersion, error)
	GetLatestVersion(ctx context.Context, bktInfo *data.BucketInfo, objectName string) (*data.NodeVersion, error)
	InitVersionsByPrefixStream(ctx context.Context, bktInfo *data.BucketInfo, prefix string, latestOnly bool) (data.VersionsStream, error)
	GetUnversioned(ctx context.Context, bktInfo *data.BucketInfo, objectName string) (*data.NodeVersion, error)
	AddVersion(ctx context.Context, bktInfo *data.BucketInfo, newVersion *data.NodeVersion) (uint64, error)
	RemoveVersion(ctx context.Context, bktInfo *data.BucketInfo, nodeID uint64) error

	PutLock(ctx context.Context, bktInfo *data.BucketInfo, nodeID uint64, lock *data.LockInfo) error
	GetLock(ctx context.Context, bktInfo *data.BucketInfo, nodeID uint64) (*data.LockInfo, error)

	CreateMultipartUpload(ctx context.Context, bktInfo *data.BucketInfo, info *data.MultipartInfo) error
	DeleteMultipartUpload(ctx context.Context, bktInfo *data.BucketInfo, info *data.MultipartInfo) error
	GetMultipartUploadsByPrefix(ctx context.Context, bktInfo *data.BucketInfo, prefix string) ([]*data.MultipartInfo, error)
	GetMultipartUpload(ctx context.Context, bktInfo *data.BucketInfo, objectName, uploadID string) (*data.MultipartInfo, error)

	// AddPart puts a node to a system tree as a child of appropriate multipart upload
	// and returns objectID of a previous part which must be deleted in FrostFS.
	//
	// If object id to remove is not found returns ErrNoNodeToRemove error.
	AddPart(ctx context.Context, bktInfo *data.BucketInfo, multipartNodeID uint64, info *data.PartInfo) (oldObjIDToDelete oid.ID, err error)
	GetParts(ctx context.Context, bktInfo *data.BucketInfo, multipartNodeID uint64) ([]*data.PartInfo, error)

	// GetObjectTaggingAndLock unifies GetObjectTagging and GetLock methods in single tree service invocation.
	GetObjectTaggingAndLock(ctx context.Context, bktInfo *data.BucketInfo, objVersion *data.NodeVersion) (map[string]string, *data.LockInfo, error)
}

TreeService provide interface to interact with tree service using s3 data models.

type TreeServiceMock

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

func NewTreeService

func NewTreeService() *TreeServiceMock

func (*TreeServiceMock) AddPart

func (t *TreeServiceMock) AddPart(ctx context.Context, bktInfo *data.BucketInfo, multipartNodeID uint64, info *data.PartInfo) (oldObjIDToDelete oid.ID, err error)

func (*TreeServiceMock) AddVersion

func (t *TreeServiceMock) AddVersion(_ context.Context, bktInfo *data.BucketInfo, newVersion *data.NodeVersion) (uint64, error)

func (*TreeServiceMock) CreateMultipartUpload

func (t *TreeServiceMock) CreateMultipartUpload(_ context.Context, bktInfo *data.BucketInfo, info *data.MultipartInfo) error

func (*TreeServiceMock) DeleteBucketCORS

func (t *TreeServiceMock) DeleteBucketCORS(context.Context, *data.BucketInfo) ([]oid.ID, error)

func (*TreeServiceMock) DeleteBucketTagging

func (t *TreeServiceMock) DeleteBucketTagging(context.Context, *data.BucketInfo) error

func (*TreeServiceMock) DeleteMultipartUpload

func (t *TreeServiceMock) DeleteMultipartUpload(_ context.Context, bktInfo *data.BucketInfo, multipartInfo *data.MultipartInfo) error

func (*TreeServiceMock) DeleteObjectTagging

func (t *TreeServiceMock) DeleteObjectTagging(ctx context.Context, bktInfo *data.BucketInfo, objVersion *data.NodeVersion) error

func (*TreeServiceMock) GetAllVersionsByPrefix

func (t *TreeServiceMock) GetAllVersionsByPrefix(_ context.Context, bktInfo *data.BucketInfo, prefix string) ([]*data.NodeVersion, error)

func (*TreeServiceMock) GetBucketCORS

func (t *TreeServiceMock) GetBucketCORS(_ context.Context, bktInfo *data.BucketInfo) (oid.ID, error)

func (*TreeServiceMock) GetBucketTagging

func (t *TreeServiceMock) GetBucketTagging(context.Context, *data.BucketInfo) (map[string]string, error)

func (*TreeServiceMock) GetLatestVersion

func (t *TreeServiceMock) GetLatestVersion(_ context.Context, bktInfo *data.BucketInfo, objectName string) (*data.NodeVersion, error)

func (*TreeServiceMock) GetLock

func (t *TreeServiceMock) GetLock(_ context.Context, bktInfo *data.BucketInfo, nodeID uint64) (*data.LockInfo, error)

func (*TreeServiceMock) GetMultipartUpload

func (t *TreeServiceMock) GetMultipartUpload(_ context.Context, bktInfo *data.BucketInfo, objectName, uploadID string) (*data.MultipartInfo, error)

func (*TreeServiceMock) GetMultipartUploadsByPrefix

func (t *TreeServiceMock) GetMultipartUploadsByPrefix(context.Context, *data.BucketInfo, string) ([]*data.MultipartInfo, error)

func (*TreeServiceMock) GetObjectTagging

func (t *TreeServiceMock) GetObjectTagging(_ context.Context, bktInfo *data.BucketInfo, nodeVersion *data.NodeVersion) (map[string]string, error)

func (*TreeServiceMock) GetObjectTaggingAndLock

func (t *TreeServiceMock) GetObjectTaggingAndLock(ctx context.Context, bktInfo *data.BucketInfo, objVersion *data.NodeVersion) (map[string]string, *data.LockInfo, error)

func (*TreeServiceMock) GetParts

func (t *TreeServiceMock) GetParts(_ context.Context, bktInfo *data.BucketInfo, multipartNodeID uint64) ([]*data.PartInfo, error)

func (*TreeServiceMock) GetSettingsNode

func (t *TreeServiceMock) GetSettingsNode(_ context.Context, bktInfo *data.BucketInfo) (*data.BucketSettings, error)

func (*TreeServiceMock) GetUnversioned

func (t *TreeServiceMock) GetUnversioned(_ context.Context, bktInfo *data.BucketInfo, objectName string) (*data.NodeVersion, error)

func (*TreeServiceMock) GetVersions

func (t *TreeServiceMock) GetVersions(_ context.Context, bktInfo *data.BucketInfo, objectName string) ([]*data.NodeVersion, error)

func (*TreeServiceMock) InitVersionsByPrefixStream added in v0.29.0

func (t *TreeServiceMock) InitVersionsByPrefixStream(_ context.Context, bktInfo *data.BucketInfo, prefix string, latestOnly bool) (data.VersionsStream, error)

func (*TreeServiceMock) PutBucketCORS

func (t *TreeServiceMock) PutBucketCORS(_ context.Context, bktInfo *data.BucketInfo, objID oid.ID) ([]oid.ID, error)

func (*TreeServiceMock) PutBucketTagging

func (t *TreeServiceMock) PutBucketTagging(context.Context, *data.BucketInfo, map[string]string) error

func (*TreeServiceMock) PutLock

func (t *TreeServiceMock) PutLock(_ context.Context, bktInfo *data.BucketInfo, nodeID uint64, lock *data.LockInfo) error

func (*TreeServiceMock) PutObjectTagging

func (t *TreeServiceMock) PutObjectTagging(_ context.Context, bktInfo *data.BucketInfo, nodeVersion *data.NodeVersion, tagSet map[string]string) error

func (*TreeServiceMock) PutSettingsNode

func (t *TreeServiceMock) PutSettingsNode(_ context.Context, bktInfo *data.BucketInfo, settings *data.BucketSettings) error

func (*TreeServiceMock) RemoveVersion

func (t *TreeServiceMock) RemoveVersion(_ context.Context, bktInfo *data.BucketInfo, nodeID uint64) error

type UploadCopyParams

type UploadCopyParams struct {
	Versioned     bool
	Info          *UploadInfoParams
	SrcObjInfo    *data.ObjectInfo
	SrcBktInfo    *data.BucketInfo
	SrcEncryption encryption.Params
	PartNumber    int
	Range         *RangeParams
}

type UploadData

type UploadData struct {
	TagSet map[string]string
}

type UploadInfo

type UploadInfo struct {
	IsDir    bool
	Key      string
	UploadID string
	Owner    user.ID
	Created  time.Time
}

type UploadInfoParams

type UploadInfoParams struct {
	UploadID   string
	Bkt        *data.BucketInfo
	Key        string
	Encryption encryption.Params
}

type UploadPartParams

type UploadPartParams struct {
	Info              *UploadInfoParams
	PartNumber        int
	Size              uint64
	Reader            io.Reader
	ContentMD5        string
	ContentSHA256Hash string
}

type VersionedObject

type VersionedObject struct {
	Name              string
	VersionID         string
	DeleteMarkVersion string
	DeleteMarkerEtag  string
	Error             error
}

VersionedObject stores info about objects to delete.

func (*VersionedObject) String

func (t *VersionedObject) String() string

type VersionsByPrefixStreamMock added in v0.29.0

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

func (*VersionsByPrefixStreamMock) Next added in v0.29.0

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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