Documentation
¶
Index ¶
- func IsConflict(err error) bool
- func IsNotFound(err error) bool
- func IsRetriableError(err error) bool
- type Fake
- func (f *Fake) BlobExists(containerName, blobName string) bool
- func (f *Fake) ContainerExists(ctx context.Context, containerName string) (bool, error)
- func (f *Fake) CreateContainer(ctx context.Context, containerName string) error
- func (f *Fake) DeleteBlob(ctx context.Context, containerName string, blobName string) error
- func (f *Fake) EnsureContainer(ctx context.Context, containerName string) error
- func (f *Fake) GetBlob(ctx context.Context, containerName, blobName string) ([]byte, error)
- func (f *Fake) GetContainer(containerName string) map[string]*blobData
- func (f *Fake) GetMetadata(ctx context.Context, containerName, blobName string) (map[string]*string, error)
- func (f *Fake) NewListBlobsFlatPager(containerName string, options *azblob.ListBlobsFlatOptions) *runtime.Pager[azblob.ListBlobsFlatResponse]
- func (f *Fake) UploadBlob(ctx context.Context, containerName, blobName string, md map[string]*string, ...) error
- type Ops
- type Real
- func (r *Real) ContainerExists(ctx context.Context, containerName string) (bool, error)
- func (r *Real) CreateContainer(ctx context.Context, containerName string) error
- func (r *Real) DeleteBlob(ctx context.Context, containerName string, blobName string) error
- func (r *Real) EnsureContainer(ctx context.Context, containerName string) error
- func (r *Real) GetBlob(ctx context.Context, containerName, blobName string) ([]byte, error)
- func (r *Real) GetMetadata(ctx context.Context, containerName, blobName string) (map[string]*string, error)
- func (r *Real) NewListBlobsFlatPager(containerName string, o *azblob.ListBlobsFlatOptions) *runtime.Pager[azblob.ListBlobsFlatResponse]
- func (r *Real) UploadBlob(ctx context.Context, containerName, blobName string, md map[string]*string, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsConflict ¶
IsConflict returns true if the error is a conflict error (already exists).
func IsNotFound ¶
IsNotFound returns true if the error is a not found error.
func IsRetriableError ¶
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 (*Fake) BlobExists ¶
BlobExists checks if a blob exists in a container.
func (*Fake) ContainerExists ¶
ContainerExists checks if a container exists.
func (*Fake) CreateContainer ¶
CreateContainer creates a container.
func (*Fake) DeleteBlob ¶
DeleteBlob deletes the specified blob from the given container.
func (*Fake) EnsureContainer ¶
EnsureContainer creates a container if it doesn't exist.
func (*Fake) GetContainer ¶
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.
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 ¶
Real implements the Ops interface using the Azure Blob Storage SDK.
func (*Real) ContainerExists ¶
ContainerExists checks if a container exists.
func (*Real) CreateContainer ¶
CreateContainer creates a container if it doesn't exist.
func (*Real) DeleteBlob ¶
DeleteBlob deletes the specified blob from the given container.
func (*Real) EnsureContainer ¶
EnsureContainer creates a container if it doesn't exist.
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.