blobops

package
v0.0.0-...-7fb7bdf Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsConflict

func IsConflict(err error) bool

IsConflict returns true if the error is a conflict error (already exists).

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the error is a not found error.

func IsRetriableError

func IsRetriableError(err error) bool

IsRetriableError returns true if the error is a retriable error. Retriable errors are typically transient network or service errors.

Types

type Fake

type Fake struct {

	// Error injection functions - if set, these will be called and their error returned
	CreateContainerErr       func(containerName string) error
	EnsureContainerErr       func(containerName string) error
	ContainerExistsErr       func(containerName string) error
	UploadBlobErr            func(containerName, blobName string) error
	DeleteBlobErr            func(containerName, blobName string) error
	GetMetadataErr           func(containerName, blobName string) error
	GetBlobErr               func(containerName, blobName string) error
	NewListBlobsFlatPagerErr func(containerName string) error
	// contains filtered or unexported fields
}

Fake implements the Ops interface for testing purposes. It stores blobs in memory and can be configured to return errors.

func NewFake

func NewFake() *Fake

NewFake creates a new fake blobops client.

func (*Fake) BlobExists

func (f *Fake) BlobExists(containerName, blobName string) bool

BlobExists checks if a blob exists in a container.

func (*Fake) ContainerExists

func (f *Fake) ContainerExists(ctx context.Context, containerName string) (bool, error)

ContainerExists checks if a container exists.

func (*Fake) CreateContainer

func (f *Fake) CreateContainer(ctx context.Context, containerName string) error

CreateContainer creates a container.

func (*Fake) DeleteBlob

func (f *Fake) DeleteBlob(ctx context.Context, containerName string, blobName string) error

DeleteBlob deletes the specified blob from the given container.

func (*Fake) EnsureContainer

func (f *Fake) EnsureContainer(ctx context.Context, containerName string) error

EnsureContainer creates a container if it doesn't exist.

func (*Fake) GetBlob

func (f *Fake) GetBlob(ctx context.Context, containerName, blobName string) ([]byte, error)

GetBlob downloads the blob data.

func (*Fake) GetContainer

func (f *Fake) GetContainer(containerName string) map[string]*blobData

GetContainer returns the blobs in a container for test assertions.

func (*Fake) GetMetadata

func (f *Fake) GetMetadata(ctx context.Context, containerName, blobName string) (map[string]*string, error)

GetMetadata retrieves the metadata of a blob.

func (*Fake) NewListBlobsFlatPager

func (f *Fake) NewListBlobsFlatPager(containerName string, options *azblob.ListBlobsFlatOptions) *runtime.Pager[azblob.ListBlobsFlatResponse]

NewListBlobsFlatPager creates a pager for listing blobs in a container. Note: This is a simplified implementation for testing purposes.

func (*Fake) UploadBlob

func (f *Fake) UploadBlob(ctx context.Context, containerName, blobName string, md map[string]*string, data []byte) error

UploadBlob uploads a blob with the given metadata and data.

type Ops

type Ops interface {
	// CreateContainer creates a container.
	CreateContainer(ctx context.Context, containerName string) error
	// EnsureContainer creates a container if it doesn't exist.
	EnsureContainer(ctx context.Context, containerName string) error
	// ContainerExists checks if a container exists.
	ContainerExists(ctx context.Context, containerName string) (bool, error)
	// UploadBlob uploads a blob with the given metadata and data. md can be nil.
	UploadBlob(ctx context.Context, containerName, blobName string, md map[string]*string, data []byte) error
	// DeleteBlob deletes the specified blob from the given container.
	DeleteBlob(ctx context.Context, containerName string, blobName string) error
	// GetMetadata retrieves the metadata of a blob.
	GetMetadata(ctx context.Context, containerName, blobName string) (map[string]*string, error)
	// GetBlob downloads the blob data.
	GetBlob(ctx context.Context, containerName, blobName string) ([]byte, error)

	// NewListBlobsFlatPager creates a pager for listing blobs in a container.
	// Returns a pager that can be used to iterate through blob listings.
	NewListBlobsFlatPager(containerName string, options *azblob.ListBlobsFlatOptions) *runtime.Pager[azblob.ListBlobsFlatResponse]
}

Ops defines operations for interacting with Azure Blob Storage.

type Real

type Real struct {
	Client *azblob.Client
}

Real implements the Ops interface using the Azure Blob Storage SDK.

func (*Real) ContainerExists

func (r *Real) ContainerExists(ctx context.Context, containerName string) (bool, error)

ContainerExists checks if a container exists.

func (*Real) CreateContainer

func (r *Real) CreateContainer(ctx context.Context, containerName string) error

CreateContainer creates a container if it doesn't exist.

func (*Real) DeleteBlob

func (r *Real) DeleteBlob(ctx context.Context, containerName string, blobName string) error

DeleteBlob deletes the specified blob from the given container.

func (*Real) EnsureContainer

func (r *Real) EnsureContainer(ctx context.Context, containerName string) error

EnsureContainer creates a container if it doesn't exist.

func (*Real) GetBlob

func (r *Real) GetBlob(ctx context.Context, containerName, blobName string) ([]byte, error)

GetBlob downloads the blob data.

func (*Real) GetMetadata

func (r *Real) GetMetadata(ctx context.Context, containerName, blobName string) (map[string]*string, error)

GetMetadata retrieves the metadata of a blob.

func (*Real) NewListBlobsFlatPager

func (r *Real) NewListBlobsFlatPager(containerName string, o *azblob.ListBlobsFlatOptions) *runtime.Pager[azblob.ListBlobsFlatResponse]

NewListBlobsFlatPager creates a new pager to list blobs in a container.

func (*Real) UploadBlob

func (r *Real) UploadBlob(ctx context.Context, containerName, blobName string, md map[string]*string, data []byte) error

UploadBlob uploads a blob with retry logic.

Jump to

Keyboard shortcuts

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