objstore

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBucketDoesntExist = errors.New("bucket doesn't exists")
)

Functions

func NewCredsSvc

func NewCredsSvc(ctx context.Context, conf *Config, rc redis.UniversalClient) (*credsSvc, error)

func NewRegistry

func NewRegistry(ctx context.Context, creds CredsService, metricsSvc metrics.Service) (*clients, error)

TODO: TODO-DC: todos for dynamic credentials support: - use DynamicCredeintilas Service everywhere instead of using Storage Config directly - use this Clients registry everywhere instead of using providers directly After done, make sure that: - Storage config is used only in this package. Other packages use only DynamicCredentials Service - Storage clients (S3|Swift) not instanitated outside of this package Then: - implement management API for dynamic credentials - add e2e tests

func StorageTypeFromRequest

func StorageTypeFromRequest(r *http.Request) dom.StorageType

StorageTypeFromRequest detects storage type from http request

func WithAfter added in v0.7.1

func WithAfter(after string) func(o *commonListOptions)

func WithLimit added in v0.7.3

func WithLimit(limit uint32) func(o *commonListOptions)

func WithPrefix added in v0.7.1

func WithPrefix(prefix string) func(o *commonListOptions)

func WithVersionID added in v0.7.1

func WithVersionID(versionID string) func(o *commonObjectOptions)

func WithVersions added in v0.7.1

func WithVersions() func(o *commonListOptions)

Types

type Clients

type Clients interface {
	AsS3(ctx context.Context, storage, user string) (s3client.Client, error)
	AsSwift(ctx context.Context, storage, user string) (*gophercloud.ServiceClient, error)
	// contains filtered or unexported methods
}

type Common

type Common interface {
	BucketExists(ctx context.Context, bucket string) (bool, error)
	IsBucketVersioned(ctx context.Context, bucket string) (bool, error)
	ListBuckets(ctx context.Context) ([]string, error)
	CreateBucket(ctx context.Context, bucket string) error
	RemoveBucket(ctx context.Context, bucket string) error
	EnableBucketVersioning(ctx context.Context, bucket string) error
	GetObject(ctx context.Context, bucket string, name string, opts ...func(o *commonObjectOptions)) (io.Reader, error)
	PutObject(ctx context.Context, bucket string, name string, reader io.Reader, len uint64) error
	ObjectInfo(ctx context.Context, bucket string, name string, opts ...func(o *commonObjectOptions)) (*CommonObjectInfo, error)
	ObjectExists(ctx context.Context, bucket string, name string, opts ...func(o *commonObjectOptions)) (bool, error)
	RemoveObject(ctx context.Context, bucket string, name string, opts ...func(o *commonObjectOptions)) error
	RemoveObjects(ctx context.Context, bucket string, names []string) []error
	RemoveObjectsSingleErr(ctx context.Context, bucket string, names []string) error
	RemoveVersionedObjects(ctx context.Context, bucket string, objects []NameAndVersion) []error
	ListObjects(ctx context.Context, bucket string, opts ...func(o *commonListOptions)) iter.Seq2[CommonObjectInfo, error]
}

Common - common object storage client interface

func WrapS3common added in v0.7.1

func WrapS3common(client s3client.Client, provider s3.Provider) Common

func WrapSwiftCommon added in v0.7.1

func WrapSwiftCommon(client *gophercloud.ServiceClient) Common

type CommonConfig

type CommonConfig struct {
	Type      dom.StorageType     `yaml:"type"`
	RateLimit ratelimit.RateLimit `yaml:"rateLimit"`
}

type CommonObjectInfo added in v0.7.1

type CommonObjectInfo struct {
	LastModified time.Time
	Key          string
	VersionID    string
	Etag         string
	Size         uint64
}

type Config

type Config = StoragesConfig[*s3.Storage, *swift.Storage]

type CredsService

type CredsService interface {
	FindS3Credentials(storage, accessKey string) (user string, cred s3.CredentialsV4, err error)
	MainStorage() string
	Storages() map[string]dom.StorageType
	GetS3Address(storage string) (s3.StorageAddress, error)
	GetSwiftAddress(storage string) (swift.StorageAddress, error)
	ValidateReplicationID(id entity.UniversalReplicationID) error
	HasUser(storage, user string) error
	ListUsers(storage string) []string

	GetSwiftCredentials(storage, user string) (swift.Credentials, error)
	GetS3Credentials(storage, user string) (s3.CredentialsV4, error)

	SetSwiftCredentials(ctx context.Context, storage, user string, cred swift.Credentials) error
	SetS3Credentials(ctx context.Context, storage, user string, cred s3.CredentialsV4) error
}

type DynamicCredentialsConfig

type DynamicCredentialsConfig struct {
	MasterPassword    string        `yaml:"masterPassword"`
	PollInterval      time.Duration `yaml:"pollInterval"`
	Enabled           bool          `yaml:"enabled"`
	DisableEncryption bool          `yaml:"disableEncryption"`
}

func (*DynamicCredentialsConfig) Validate

func (c *DynamicCredentialsConfig) Validate() error

type GenericStorage

type GenericStorage[
	S3Config StorageConfig,
	SwiftConfig StorageConfig,
] struct {
	S3    S3Config
	Swift SwiftConfig
	CommonConfig
}

func (GenericStorage[S3conf, SwiftConf]) MarshalYAML

func (a GenericStorage[S3conf, SwiftConf]) MarshalYAML() (any, error)

func (*GenericStorage[S3conf, SwiftConf]) UnmarshalYAML

func (s *GenericStorage[S3conf, SwiftConf]) UnmarshalYAML(node *yaml.Node) error

func (GenericStorage[S3conf, SwiftConf]) UserList

func (a GenericStorage[S3conf, SwiftConf]) UserList() []string

func (GenericStorage[S3Config, SwiftConfig]) Validate

func (s GenericStorage[S3Config, SwiftConfig]) Validate() error

type NameAndVersion added in v0.7.3

type NameAndVersion struct {
	Name    string
	Version string
}

type Storage

type Storage = GenericStorage[*s3.Storage, *swift.Storage]

type StorageConfig

type StorageConfig interface {
	Validate() error
	UserList() []string
	HasUser(user string) bool
	comparable
}

type StoragesConfig

type StoragesConfig[
	S3Config StorageConfig,
	SwiftConfig StorageConfig,
] struct {
	Storages           map[string]GenericStorage[S3Config, SwiftConfig] `yaml:"storages"`
	Main               string                                           `yaml:"main"`
	DynamicCredentials DynamicCredentialsConfig                         `yaml:"dynamicCredentials"`
}

func (StoragesConfig[S3Config, SwiftConfig]) Exists

func (s StoragesConfig[S3Config, SwiftConfig]) Exists(stor, user string) error

func (StoragesConfig[S3conf, SwiftConf]) GetMain

func (s StoragesConfig[S3conf, SwiftConf]) GetMain() GenericStorage[S3conf, SwiftConf]

func (StoragesConfig[_, _]) RateLimitConf

func (s StoragesConfig[_, _]) RateLimitConf() map[string]ratelimit.RateLimit

func (StoragesConfig[S3conf, SwiftConf]) S3Storages

func (s StoragesConfig[S3conf, SwiftConf]) S3Storages() map[string]S3conf

func (StoragesConfig[S3conf, SwiftConf]) SwiftStorages

func (s StoragesConfig[S3conf, SwiftConf]) SwiftStorages() map[string]SwiftConf

func (StoragesConfig[S3Config, SwiftConfig]) Types

func (s StoragesConfig[S3Config, SwiftConfig]) Types() map[string]dom.StorageType

func (StoragesConfig[_, _]) Validate

func (s StoragesConfig[_, _]) Validate() error

Jump to

Keyboard shortcuts

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