gcp

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// IteratorDone is returned when the looping of objects/content
	// has reached the end of the iteration.
	IteratorDone = iterator.Done
	// ErrorDirectoryExists is an error returned when the filename provided
	// is a directory.
	ErrorDirectoryExists = errors.New("filename is a directory")
	// ErrorObjectDoesNotExist is an error returned when the object whose name
	// is provided does not exist.
	ErrorObjectDoesNotExist = errors.New("object does not exist")
)

Functions

func ValidateSecret

func ValidateSecret(secret map[string][]byte, name string) error

ValidateSecret validates the credential secrets It ensures that needed secret fields are not missing.

Types

type GCPClient

type GCPClient struct {
	// client for interacting with the Google Cloud
	// Storage APIs.
	*gcpstorage.Client
}

func NewClient

func NewClient(ctx context.Context, opts ...option.ClientOption) (*GCPClient, error)

NewClient creates a new GCP storage client. The Client will automatically look for the Google Application Credential environment variable or look for the Google Application Credential file.

func (*GCPClient) BucketExists

func (c *GCPClient) BucketExists(ctx context.Context, bucketName string) (bool, error)

BucketExists checks if the bucket with the provided name exists.

func (*GCPClient) Close

func (c *GCPClient) Close(log logr.Logger)

Close closes the GCP Client and logs any useful errors

func (*GCPClient) FGetObject

func (c *GCPClient) FGetObject(ctx context.Context, bucketName, objectName, localPath string) error

FGetObject gets the object from the bucket and downloads the object locally

func (*GCPClient) ListObjects

func (c *GCPClient) ListObjects(ctx context.Context, bucketName string, query *gcpstorage.Query) *gcpstorage.ObjectIterator

ListObjects lists the objects/contents of the bucket whose bucket name is provided. the objects are returned as an Objectiterator and .Next() has to be called on them to loop through the Objects.

func (*GCPClient) ObjectExists

func (c *GCPClient) ObjectExists(ctx context.Context, bucketName, objectName string) (bool, error)

ObjectExists checks if the object with the provided name exists.

Jump to

Keyboard shortcuts

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