gcp

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: Apache-2.0 Imports: 16 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, opts ...Option) (*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, prefix 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.

type Option added in v1.4.0

type Option func(*options)

Option is a functional option for configuring the GCS client.

func WithProxyURL added in v1.4.0

func WithProxyURL(proxyURL *url.URL) Option

WithProxyURL sets the proxy URL to use for the GCS client.

func WithSecret added in v1.4.0

func WithSecret(secret *corev1.Secret) Option

WithSecret sets the secret to use for authenticating with GCP.

Jump to

Keyboard shortcuts

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