gcp

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: Apache-2.0 Imports: 12 Imported by: 1

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")
)

Functions

func ValidateSecret

func ValidateSecret(secret *corev1.Secret) error

ValidateSecret validates the credential secret. The provided Secret may be nil.

Types

type GCSClient added in v0.22.0

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

GCSClient is a minimal Google Cloud Storage client for fetching objects.

func NewClient

func NewClient(ctx context.Context, secret *corev1.Secret) (*GCSClient, 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 (*GCSClient) BucketExists added in v0.22.0

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

BucketExists returns if an object storage bucket with the provided name exists, or returns a (client) error.

func (*GCSClient) Close added in v0.22.0

func (c *GCSClient) Close(ctx context.Context)

Close closes the GCP Client and logs any useful errors.

func (*GCSClient) FGetObject added in v0.22.0

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

FGetObject gets the object from the provided object storage bucket, and writes it to targetPath. It returns the etag of the successfully fetched file, or any error.

func (*GCSClient) ObjectIsNotFound added in v0.22.0

func (c *GCSClient) ObjectIsNotFound(err error) bool

ObjectIsNotFound checks if the error provided is storage.ErrObjectNotExist.

func (*GCSClient) VisitObjects added in v0.22.0

func (c *GCSClient) VisitObjects(ctx context.Context, bucketName string, visit func(path, etag string) error) error

VisitObjects iterates over the items in the provided object storage bucket, calling visit for every item. If the underlying client or the visit callback returns an error, it returns early.

Jump to

Keyboard shortcuts

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