objectstore

package
v0.113.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const REGIONAL = "REGIONAL"

Variables

This section is empty.

Functions

func IsBucketNotFoundError

func IsBucketNotFoundError(err error) bool

func IsS3Provider

func IsS3Provider(p Provider) bool

IsS3Provider is a helper function to find out if a provider is an s3Provider

func Supported

func Supported(t ProviderType) bool

Supported returns true if the object store type is supported

Types

type Bucket

type Bucket interface {
	Directory
}

Bucket abstracts the object store of different cloud providers

type Directory

type Directory interface {
	// CreateDirectory creates a sub directory
	CreateDirectory(context.Context, string) (Directory, error)

	// GetDirectory gets the sub directory
	GetDirectory(context.Context, string) (Directory, error)

	// DeleteDirectory deletes the current directory
	DeleteDirectory(context.Context) error

	// DeleteAllWithPrefix deletes all directories and objects with a provided prefix
	DeleteAllWithPrefix(context.Context, string) error

	// ListDirectories lists all the directories rooted in
	// the current directory and their handle
	ListDirectories(context.Context) (map[string]Directory, error)

	// ListObjects lists all the objects rooted in the current directory
	ListObjects(context.Context) ([]string, error)

	// Get returns the io interface to read object data
	Get(context.Context, string) (io.ReadCloser, map[string]string, error)

	// Get returns bytes in the named object
	GetBytes(context.Context, string) ([]byte, map[string]string, error)

	// Put persists data from the Reader interface in the named object
	Put(context.Context, string, io.Reader, int64, map[string]string) error

	// Put persists bytes in the named object
	PutBytes(context.Context, string, []byte, map[string]string) error

	// Delete removes the object
	Delete(context.Context, string) error

	// Serialize directory
	String() string
}

Directory operations

func GetOrCreateBucket

func GetOrCreateBucket(ctx context.Context, p Provider, bucketName string) (Directory, error)

GetOrCreateBucket is a helper function to access the package level getOrCreateBucket

type Provider

type Provider interface {
	// CreateBucket creates a new bucket. Bucket name must
	// honors provider naming restrictions
	CreateBucket(context.Context, string) (Bucket, error)

	// GetBucket access a specific bucket
	GetBucket(context.Context, string) (Bucket, error)

	// DeleteBucket deletes the bucket
	DeleteBucket(context.Context, string) error

	// ListBuckets returns all buckets and their Directory handle
	ListBuckets(context.Context) (map[string]Bucket, error)
	// contains filtered or unexported methods
}

Provider abstracts actions on cloud provider bucket

func NewProvider

func NewProvider(ctx context.Context, config ProviderConfig, secret *Secret) (Provider, error)

NewProvider creates a new Provider

type ProviderConfig

type ProviderConfig struct {
	// object store type
	Type ProviderType
	// Endpoint used to access the object store. It can be implicit for
	// stores from certain cloud providers such as AWS. In that case it can
	// be empty
	Endpoint string
	// Region specifies the region of the object store.
	Region string
	// If true, disable SSL verification. If false (the default), SSL
	// verification is enabled.
	SkipSSLVerify bool
}

ProviderConfig describes the config for the object store (which provider to use)

type ProviderType

type ProviderType string

ProviderType enum for different providers

const (
	// ProviderTypeGCS captures enum value "GCS"
	ProviderTypeGCS ProviderType = "GCS"
	// ProviderTypeS3 captures enum value "S3"
	ProviderTypeS3 ProviderType = "S3"
	// ProviderTypeAzure captures enum value "Azure"
	ProviderTypeAzure ProviderType = "Azure"
)

type Secret

type Secret struct {
	// aws
	Aws *SecretAws
	// azure
	Azure *SecretAzure
	// gcp
	Gcp *SecretGcp
	// type
	Type SecretType
}

Secret contains the credentials for different providers

type SecretAws

type SecretAws struct {
	// access key Id
	AccessKeyID string
	// secret access key
	SecretAccessKey string
	// session token
	SessionToken string
}

SecretAws AWS keys

type SecretAzure

type SecretAzure struct {
	// storage account
	StorageAccount string
	// storage key
	StorageKey string
	// environment name
	EnvironmentName string
}

SecretAzure Azure credentials

type SecretGcp

type SecretGcp struct {
	// project Id
	ProjectID string
	// base64 encoded service account key
	ServiceKey string
}

SecretGcp GCP credentials

type SecretType

type SecretType string

SecretType enum for different providers

const (
	// SecretTypeAwsAccessKey captures enum value "AwsAccessKey"
	SecretTypeAwsAccessKey SecretType = "AwsAccessKey"
	// SecretTypeGcpServiceAccountKey captures enum value "GcpServiceAccountKey"
	SecretTypeGcpServiceAccountKey SecretType = "GcpServiceAccountKey"
	// SecretTypeAzStorageAccount captures enum value "AzStorageAccount"
	SecretTypeAzStorageAccount SecretType = "AzStorageAccount"
)

Jump to

Keyboard shortcuts

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