utils

package
v0.0.0-...-a7fc55d Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChmodIfPermissionMismatch

func ChmodIfPermissionMismatch(targetPath string, mode os.FileMode) error

ChmodIfPermissionMismatch checks the permission of the targetPath and chmod it if it's different from the mode.

func GetServerFromSource

func GetServerFromSource(server string) string

GetServerFromSource returns the server address from the source.

func LogGRPC

func LogGRPC(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

LogGRPC is a middleware function that logs the details of a gRPC call. It logs the method, request, and response using the klog package. The log level is determined based on the method. It returns the response and any error from the handler.

func ParseEndpoint

func ParseEndpoint(endpoint string) (string, string, error)

ParseEndpoint parses the given endpoint and returns the protocol and address. It supports both "unix://" and "tcp://" protocols. If the endpoint is invalid, it returns an error.

Types

type Config

type Config struct {
	AccessKeyID     string
	SecretAccessKey string
	Region          string
	Endpoint        string
	Mounter         string
}

Config holds values to configure the driver

type Metadata

type Metadata struct {
	BucketName    string   `json:"Name"`
	Prefix        string   `json:"Prefix"`
	Mounter       string   `json:"Mounter"`
	MountOptions  []string `json:"MountOptions"`
	CapacityBytes int64    `json:"CapacityBytes"`
}

Metadata holds the metadata of a volume

type S3Client

type S3Client struct {
	Config *Config
	Minio  *minio.Client
	Ctx    context.Context
}

S3Client is a client

func NewClientFromSecrets

func NewClientFromSecrets(secrets map[string]string) (*S3Client, error)

NewClientFromSecrets creates a new S3Client from secrets

func NewS3Client

func NewS3Client(cfg *Config) (*S3Client, error)

NewS3Client creates a new S3Client

func (*S3Client) CreateBucket

func (c *S3Client) CreateBucket(bucketName string) error

CreateBucket creates a new bucket

func (*S3Client) CreatePrefix

func (c *S3Client) CreatePrefix(bucketName, prefix string) error

CreatePrefix creates a new prefix

func (*S3Client) DeleteBucket

func (c *S3Client) DeleteBucket(bucketName string) error

DeleteBucket deletes a bucket

func (*S3Client) DeletePrefix

func (c *S3Client) DeletePrefix(bucketName, prefix string) error

DeletePrefix deletes a prefix

func (*S3Client) IsBucketExist

func (c *S3Client) IsBucketExist(bucketName string) (bool, error)

IsBucketExist checks if a bucket exists

type VolumeLocks

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

func NewVolumeLocks

func NewVolumeLocks() *VolumeLocks

func (*VolumeLocks) IsLocked

func (v *VolumeLocks) IsLocked(volumeID string) bool

IsLocked returns true if the volume is locked.

func (*VolumeLocks) Lock

func (v *VolumeLocks) Lock(volumeID string)

Lock locks the volume.

func (*VolumeLocks) Release

func (v *VolumeLocks) Release(volumeID string)

Release releases the lock for the volume.

func (*VolumeLocks) TryAcquire

func (v *VolumeLocks) TryAcquire(volumeID string) bool

TryAcquire tries to acquire the lock for the volume. If the lock is already

func (*VolumeLocks) Unlock

func (v *VolumeLocks) Unlock(volumeID string)

Unlock unlocks the volume.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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