provider

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound  = errors.New("resource not found")
	ErrDenied    = errors.New("access denied")
	ErrNoPresign = errors.New("presigning is not allowed for this provider")
	// This is a special error that the provider can return to indicate that the object has not been modified since the specified time
	// It will be translated into a 304 Not Modified response by the server
	ErrNotModified = errors.New("resource not modified")
)

Functions

This section is empty.

Types

type Config

type Config interface {
	Id() string
}

type ConfigBase

type ConfigBase struct {
	ID         string
	AuthPlugin string `json:"auth-plugin"`
}

func (*ConfigBase) Id

func (c *ConfigBase) Id() string

type GetOptions

type GetOptions struct {
	// If specified, the provider should only return the object if it has not been modified since this time, otherwise return ErrNotModified
	// If zero, the provider should return the object regardless of its modification time
	LastModified *time.Time
}

type GocloudConfig

type GocloudConfig struct {
	ConfigBase
	DriverURL string `json:"driver-url"`
}

type GocloudProvider

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

func NewGocloudProvider

func NewGocloudProvider(cfg *GocloudConfig) (*GocloudProvider, error)

func (*GocloudProvider) AuthPlugin

func (n *GocloudProvider) AuthPlugin() string

func (*GocloudProvider) DeleteObject added in v0.3.0

func (n *GocloudProvider) DeleteObject(ctx context.Context, key string) error

func (*GocloudProvider) GetObject

func (n *GocloudProvider) GetObject(ctx context.Context, key string, opts GetOptions) (io.ReadCloser, ObjectInfo, error)

func (*GocloudProvider) GetTags

func (n *GocloudProvider) GetTags(ctx context.Context, key string) (map[string]string, error)

func (*GocloudProvider) Id

func (n *GocloudProvider) Id() string

func (*GocloudProvider) ListObjects added in v0.3.0

func (n *GocloudProvider) ListObjects(ctx context.Context, prefix string) (ListObjectsResponse, error)

func (*GocloudProvider) PutObject

func (n *GocloudProvider) PutObject(ctx context.Context, key string, data io.Reader, opts PutOptions) error

type ListObjectsResponse added in v0.3.0

type ListObjectsResponse struct {
	// The keys of the objects found
	Keys []string
}

type LogConfig

type LogConfig struct {
	ConfigBase
}

type LogProvider

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

func NewLogProvider

func NewLogProvider(cfg *LogConfig) *LogProvider

func (*LogProvider) AuthPlugin

func (n *LogProvider) AuthPlugin() string

func (*LogProvider) DeleteObject added in v0.3.0

func (n *LogProvider) DeleteObject(ctx context.Context, key string) error

func (*LogProvider) GetObject

func (n *LogProvider) GetObject(ctx context.Context, key string, opts GetOptions) (io.ReadCloser, ObjectInfo, error)

func (*LogProvider) GetTags

func (n *LogProvider) GetTags(ctx context.Context, key string) (map[string]string, error)

func (*LogProvider) Id

func (n *LogProvider) Id() string

func (*LogProvider) ListObjects added in v0.3.0

func (n *LogProvider) ListObjects(ctx context.Context, prefix string) (ListObjectsResponse, error)

func (*LogProvider) PutObject

func (n *LogProvider) PutObject(ctx context.Context, key string, data io.Reader, opts PutOptions) error

type ObjectInfo

type ObjectInfo struct {
	// When the object was last modified
	LastModified *time.Time

	// The length of the object in bytes
	ContentLength *int64

	// The content type of the object
	ContentType *string
}

ObjectInfo contains metadata about an object The server will only act on the fields that are not nil

type PresignOperation

type PresignOperation string
const (
	PresignOperationDownload PresignOperation = "download"
	PresignOperationUpload   PresignOperation = "upload"
)

type Presigner

type Presigner interface {
	PresignURL(ctx context.Context, key string, direction PresignOperation) (string, error)
}

type Provider

type Provider interface {
	// Id returns the provider ID which must be unique among all providers
	Id() string
	// AuthPlugin optionally returns the name of the auth plugin that should be used for this provider
	// If the provider does not specify an auth plugin the default one will be used
	AuthPlugin() string

	GetObject(ctx context.Context, key string, opts GetOptions) (io.ReadCloser, ObjectInfo, error)
	PutObject(ctx context.Context, key string, data io.Reader, opts PutOptions) error
	GetTags(ctx context.Context, key string) (map[string]string, error)
	ListObjects(ctx context.Context, prefix string) (ListObjectsResponse, error)
	DeleteObject(ctx context.Context, key string) error
}

type ProviderType

type ProviderType string
const (
	// ProviderTypeVoid is a provider that does nothing
	ProviderTypeVoid ProviderType = "void"
	// ProviderTypeLog is a provider that logs all operations
	ProviderTypeLog ProviderType = "log"
	// ProviderTypeS3 is a provider that uses AWS S3
	ProviderTypeS3 ProviderType = "s3"
	// ProviderTypeGocloud is a provider that uses the gocloud.dev CDK
	// This will support all the providers that gocloud supports including S3, Azure, Google Cloud, file and in-memory
	ProviderTypeGocloud ProviderType = "gocloud"
)

type PutOptions added in v0.2.0

type PutOptions struct {
	// The content type of the object
	ContentType string

	ContentLength int64

	// The tags to apply to the object
	Tags map[string]string
}

type S3Config

type S3Config struct {
	ConfigBase
	Bucket         string
	Region         string
	Profile        string
	PresignEnabled bool `json:"presign-enabled"`
}

type S3Provider

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

func NewS3Provider

func NewS3Provider(cfg *S3Config) (*S3Provider, error)

func (*S3Provider) AuthPlugin

func (s *S3Provider) AuthPlugin() string

func (*S3Provider) DeleteObject added in v0.3.0

func (s *S3Provider) DeleteObject(ctx context.Context, key string) error

func (*S3Provider) GetObject

func (s *S3Provider) GetObject(ctx context.Context, key string, opts GetOptions) (io.ReadCloser, ObjectInfo, error)

func (*S3Provider) GetTags

func (s *S3Provider) GetTags(ctx context.Context, key string) (map[string]string, error)

func (*S3Provider) Id

func (s *S3Provider) Id() string

func (*S3Provider) ListObjects added in v0.3.0

func (s *S3Provider) ListObjects(ctx context.Context, prefix string) (ListObjectsResponse, error)

Does currently not support pagination but the default max is 1000 so it is fine for now. Note for future developers: output.IsTruncated is a boolean that indicates if there are more objects to retrieve and output.NextContinuationToken is the token to use for the next request.

func (*S3Provider) PresignURL

func (s *S3Provider) PresignURL(ctx context.Context, key string, op PresignOperation) (string, error)

func (*S3Provider) PutObject

func (s *S3Provider) PutObject(ctx context.Context, key string, data io.Reader, opts PutOptions) error

type VoidConfig

type VoidConfig struct {
	ConfigBase
}

type VoidProvider

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

func NewVoidProvider

func NewVoidProvider(cfg *VoidConfig) *VoidProvider

func (*VoidProvider) AuthPlugin

func (n *VoidProvider) AuthPlugin() string

func (*VoidProvider) DeleteObject added in v0.3.0

func (n *VoidProvider) DeleteObject(ctx context.Context, key string) error

func (*VoidProvider) GetObject

func (n *VoidProvider) GetObject(ctx context.Context, key string, opts GetOptions) (io.ReadCloser, ObjectInfo, error)

func (*VoidProvider) GetTags

func (n *VoidProvider) GetTags(ctx context.Context, key string) (map[string]string, error)

func (*VoidProvider) Id

func (n *VoidProvider) Id() string

func (*VoidProvider) ListObjects added in v0.3.0

func (n *VoidProvider) ListObjects(ctx context.Context, prefix string) (ListObjectsResponse, error)

func (*VoidProvider) PutObject

func (n *VoidProvider) PutObject(ctx context.Context, key string, data io.Reader, opts PutOptions) error

Jump to

Keyboard shortcuts

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