util

package
v0.5.0-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GSPrefix = "gs://"
)

Variables

This section is empty.

Functions

func Contains

func Contains(array []string, elem string) bool

Contains check whether given "elem" presents in "array"

func Filter

func Filter(slice []string, element string) []string

Filter Returns a slice that doesn't contain element

Types

type GCSUtil

type GCSUtil interface {
	// Download returns an io.ReadCloser for GCS object at given gcsPath.
	Download(ctx context.Context, gcsPath string) (io.ReadCloser, error)
	// Delete deletes all objects under given gcsPath
	Delete(ctx context.Context, gcsPath string) error
	// UploadFile uploads contents of a file at filepath to gcsPath location in
	// GCS and sets object's contentType.
	// If gcsPath ends with .gz it also compresses the uploaded contents
	// and sets object's content type to application/gzip.
	UploadFile(ctx context.Context, gcsPath, filepath, contentType string) error
	// SplitURI takes a GCS URI and splits it into bucket and object names. If the URI does not have
	// the gs:// scheme, or the URI doesn't specify both a bucket and an object name, returns an error.
	SplitURI(url string) (bucket, name string, err error)
}

GCSUtil contains helper methods for reading/writing GCS objects.

type GCSUtilImpl

type GCSUtilImpl struct{}

func (*GCSUtilImpl) Delete

func (g *GCSUtilImpl) Delete(ctx context.Context, gcsPath string) error

func (*GCSUtilImpl) Download

func (g *GCSUtilImpl) Download(ctx context.Context, gcsPath string) (io.ReadCloser, error)

func (*GCSUtilImpl) SplitURI

func (g *GCSUtilImpl) SplitURI(url string) (bucket, name string, err error)

func (*GCSUtilImpl) UploadFile

func (g *GCSUtilImpl) UploadFile(ctx context.Context, gcsPath, filePath, contentType string) error

Directories

Path Synopsis
Package task implements tasks struct and its utility methods.
Package task implements tasks struct and its utility methods.

Jump to

Keyboard shortcuts

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