storage

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareBuckets

func CompareBuckets(a, b *ServiceBucket) error

func IsNotExistErr

func IsNotExistErr(err error) bool

func ParseErrCode added in v1.5.0

func ParseErrCode(err error) codes.Code

ParseErrCode parses error and returns a gRPC code. This function is necessary because the gcsService uses two different Google Cloud clients: a gRPC-based StorageControlClient and a JSON-based vanilla GCS client. These clients return different error types.

The function first checks if the error is a gRPC status error. If so, it returns the gRPC code. This is the case for errors from the StorageControlClient (e.g., in CheckBucketExists). If not, it falls back to checking for legacy error types used by the vanilla GCS client (e.g., in GetBucket).

Types

type Service

type Service interface {
	CreateBucket(ctx context.Context, b *ServiceBucket) (*ServiceBucket, error)
	GetBucket(ctx context.Context, b *ServiceBucket) (*ServiceBucket, error)
	DeleteBucket(ctx context.Context, b *ServiceBucket) error
	SetIAMPolicy(ctx context.Context, obj *ServiceBucket, member, roleName string) error
	RemoveIAMPolicy(ctx context.Context, obj *ServiceBucket, member, roleName string) error
	CheckBucketExists(ctx context.Context, obj *ServiceBucket) (bool, error)
	UploadGCSObject(ctx context.Context, localPath, bucketName, objectName string) error
	DownloadGCSObject(ctx context.Context, bucketName, objectName, localPath string) error
	Close()
}

type ServiceBucket

type ServiceBucket struct {
	Project                        string
	Name                           string
	Location                       string
	SizeBytes                      int64
	Labels                         map[string]string
	EnableUniformBucketLevelAccess bool
	EnableHierarchicalNamespace    bool
	EnableZB                       bool // Enable Zonal Buckets
}

type ServiceManager

type ServiceManager interface {
	SetupService(ctx context.Context, ts oauth2.TokenSource) (Service, error)
	SetupServiceWithDefaultCredential(ctx context.Context, enableZB bool) (Service, error)
	SetupStorageServiceForSidecar(ctx context.Context, ts oauth2.TokenSource) (Service, error)
}

func NewFakeServiceManager

func NewFakeServiceManager() ServiceManager

func NewGCSServiceManager

func NewGCSServiceManager() (ServiceManager, error)

Jump to

Keyboard shortcuts

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