Documentation ¶
Overview ¶
package gcs provides useful utilities for GCS This package isn't specific to our groups sync. We should probably move it to a more generic location and make it its own go module to make it easy to reuse.
Index ¶
- func Base(uri string) string
- func Dir(uri string) string
- func ListObjects(ctx context.Context, client *storage.Client, uri string) ([]string, error)
- func ListObjectsWithPrefix(ctx context.Context, client *storage.Client, prefix string) ([]string, error)
- func ObjectExists(ctx context.Context, o *storage.ObjectHandle) bool
- type FileHelper
- type GcsHelper
- type GcsPath
- type LocalFileHelper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base ¶
Base should have the same semantics as Path.Base except it should work with URIs e.g. file://some and gs:// as well as non URIs
func Dir ¶
Dir should have the same semantics as Path.Dir except it should work with URIs e.g. file://some and gs:// as well as non URIs
func ListObjects ¶
ListObjects lists all objects matching some regex.
This is listing all files in the parent directory.
func ListObjectsWithPrefix ¶
func ListObjectsWithPrefix(ctx context.Context, client *storage.Client, prefix string) ([]string, error)
ListObjectsWithPrefix returns a list of all GCS objects within the given prefix.
func ObjectExists ¶
func ObjectExists(ctx context.Context, o *storage.ObjectHandle) bool
Types ¶
type FileHelper ¶
type FileHelper interface { Exists(path string) (bool, error) NewReader(path string) (io.Reader, error) NewWriter(path string) (io.Writer, error) }
FileHelper is an interface intended to transparently handle working with GCS and local files. TODO(jlewi): Move into the util package?
type GcsHelper ¶
func (*GcsHelper) BuildInputOutputList ¶
BuildInputOutputList builds a map from input files to the files that they should be mapped to.
input is a regex as specified by TransformFiles. This is used to find existing files and generate the corresponding output files.
func (*GcsHelper) Exists ¶
Exists checks whether the URI exists.
If error is not nil the boolean value will be random.
type LocalFileHelper ¶
type LocalFileHelper struct{}
func (*LocalFileHelper) Exists ¶
func (h *LocalFileHelper) Exists(uri string) (bool, error)
Exists checks whether the file exists.