storage

package
v0.0.0-testrgm6 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: AGPL-3.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorNilBucket is returned when a function is called where a bucket argument is expected and the bucket is nil.
	ErrorNilBucket = errors.New("a bucket must be provided")
)

Functions

func GetLatestMainBuild

func GetLatestMainBuild(ctx context.Context, bucket *storage.BucketHandle, path string) (string, error)

GetLatestMainBuild gets the latest main build which is successfully uploaded to the gcs bucket.

Types

type Client

type Client struct {
	storage.Client
}

Client wraps the gcloud storage Client with convenient helper functions. By using an embedded type we can still use the functions provided by storage.Client if we need to.

func New

func New() (*Client, error)

New creates a new Client by checking for the Google Cloud SDK auth key and/or environment variable.

func (*Client) Copy

func (client *Client) Copy(ctx context.Context, file File, bucket *storage.BucketHandle, remote string, trim bool) error

Copy copies a single local file into the bucket at the provided path. trim variable should be set to true if the full object path is needed - false otherwise.

func (*Client) CopyLocalDir

func (client *Client) CopyLocalDir(ctx context.Context, dir string, bucket *storage.BucketHandle, bucketPath string, trim bool) error

CopyLocalDir copies a local directory 'dir' to the bucket 'bucket' at the path 'bucketPath'.

func (*Client) CopyRemoteDir

func (client *Client) CopyRemoteDir(ctx context.Context, fromBucket *storage.BucketHandle, from string, toBucket *storage.BucketHandle, to string) error

CopyRemoteDir copies an entire directory 'from' from the bucket 'fromBucket' into the 'toBucket' at the path 'to'.

func (*Client) Delete

func (client *Client) Delete(ctx context.Context, bucket *storage.BucketHandle, path string) error

Delete deletes single item from the bucket at 'path'.

func (*Client) DeleteDir

func (client *Client) DeleteDir(ctx context.Context, bucket *storage.BucketHandle, path string) error

DeleteDir deletes a directory at 'path' from the bucket.

func (*Client) DownloadDirectory

func (client *Client) DownloadDirectory(ctx context.Context, bucket *storage.BucketHandle, destPath string, filter FilesFilter) error

DownloadDirectory downloads files from bucket (filtering by FilesFilter) to destPath on disk.

func (*Client) RemoteCopy

func (client *Client) RemoteCopy(ctx context.Context, file File, fromBucket, toBucket *storage.BucketHandle, path string) error

RemoteCopy will copy the file 'file' from the 'fromBucket' to the 'toBucket' at the path 'path'.

func (*Client) SetRetryer

func (client *Client) SetRetryer()

SetRetryer adds a retry strategy for the googleapi client calls that fail.

type File

type File struct {
	FullPath    string
	PathTrimmed string
}

File represents a file in Google Cloud Storage.

func ListLocalFiles

func ListLocalFiles(dir string) ([]File, error)

ListLocalFiles lists files in a local filesystem.

func ListRemoteFiles

func ListRemoteFiles(ctx context.Context, bucket *storage.BucketHandle, filter FilesFilter) ([]File, error)

ListRemoteFiles lists all the files in the directory (filtering by FilesFilter) and returns a File struct for each one.

type FilesFilter

type FilesFilter struct {
	Prefix   string
	FileExts []string
}

Jump to

Keyboard shortcuts

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