Documentation ¶
Index ¶
- func ConcatGCSPath(pathElements ...string) string
- func GetBucketNameFromGCSPath(p string) (string, error)
- func GetGCSObjectPathElements(p string) (string, string, error)
- func SplitGCSPath(p string) (string, string, error)
- type BucketIterator
- type BucketIteratorCreator
- type BufferedWriter
- type Client
- func (sc *Client) Buckets(projectID string) *storage.BucketIterator
- func (sc *Client) Close() error
- func (sc *Client) CreateBucket(bucketName string, project string, attrs *storage.BucketAttrs) error
- func (sc *Client) DeleteGcsPath(gcsPath string) error
- func (sc *Client) DeleteObject(gcsPath string) error
- func (sc *Client) FindGcsFile(gcsDirectoryPath string, fileExtension string) (*storage.ObjectHandle, error)
- func (sc *Client) FindGcsFileDepthLimited(gcsDirectoryPath string, fileExtension string, lookupDepth int) (*storage.ObjectHandle, error)
- func (sc *Client) GetBucket(bucket string) *storage.BucketHandle
- func (sc *Client) GetBucketAttrs(bucket string) (*storage.BucketAttrs, error)
- func (sc *Client) GetGcsFileContent(gcsObject *storage.ObjectHandle) ([]byte, error)
- func (sc *Client) GetObject(bucket string, objectPath string) domain.StorageObject
- func (sc *Client) GetObjectAttrs(bucket string, objectPath string) (*storage.ObjectAttrs, error)
- func (sc *Client) GetObjects(bucket string, objectPath string) domain.ObjectIteratorInterface
- func (sc *Client) UpdateBucket(bucketName string, attrs storage.BucketAttrsToUpdate) error
- func (sc *Client) WriteToGCS(destinationBucketName string, destinationObjectPath string, reader io.Reader) error
- type HTTPClient
- type ObjectIterator
- type ObjectIteratorCreator
- type ResourceLocationRetriever
- type ScratchBucketCreator
- type TarGcsExtractor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConcatGCSPath ¶
ConcatGCSPath concatenates multiple elements of GCS path into a GCS path.
func GetBucketNameFromGCSPath ¶
GetBucketNameFromGCSPath splits GCS path to get bucket name
func GetGCSObjectPathElements ¶
GetGCSObjectPathElements returns bucket name, object path within the bucket for a valid object path. Error is returned otherwise.
Types ¶
type BucketIterator ¶
type BucketIterator struct {
// contains filtered or unexported fields
}
BucketIterator is a wrapper around storage.BucketIterator. Implements BucketIteratorInterface.
func (*BucketIterator) Next ¶
func (bi *BucketIterator) Next() (*storage.BucketAttrs, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns iterator.Done, all subsequent calls will return iterator.Done.
type BucketIteratorCreator ¶
type BucketIteratorCreator struct { }
BucketIteratorCreator is responsible for creating GCS bucket iterator
func (*BucketIteratorCreator) CreateBucketIterator ¶
func (bic *BucketIteratorCreator) CreateBucketIterator(ctx context.Context, storageClient domain.StorageClientInterface, projectID string) domain.BucketIteratorInterface
CreateBucketIterator creates GCS bucket iterator
type BufferedWriter ¶
BufferedWriter is responsible for multipart component upload while using a local buffer.
func NewBufferedWriter ¶
func NewBufferedWriter(ctx context.Context, size, workers int64, client gcsClient, oauth, prefix, bkt, obj, errLogPrefix string) *BufferedWriter
NewBufferedWriter creates a BufferedWriter
func (*BufferedWriter) Close ¶
func (b *BufferedWriter) Close() error
Close composes the objects and close buffered writer.
type Client ¶
type Client struct { StorageClient *storage.Client Logger logging.Logger Ctx context.Context Oic domain.ObjectIteratorCreatorInterface Soc domain.StorageObjectCreatorInterface }
Client implements domain.StorageClientInterface. It implements main Storage functions used by image import features.
func NewStorageClient ¶
func NewStorageClient(ctx context.Context, logger logging.Logger, storageOptions ...option.ClientOption) (*Client, error)
NewStorageClient creates a Client
func (*Client) Buckets ¶
func (sc *Client) Buckets(projectID string) *storage.BucketIterator
Buckets returns a bucket iterator for all buckets within a project
func (*Client) CreateBucket ¶
func (sc *Client) CreateBucket( bucketName string, project string, attrs *storage.BucketAttrs) error
CreateBucket creates a GCS bucket
func (*Client) DeleteGcsPath ¶
DeleteGcsPath deletes a GCS path, including files
func (*Client) DeleteObject ¶
DeleteObject deletes the object with the path `gcsPath`.
func (*Client) FindGcsFile ¶
func (sc *Client) FindGcsFile(gcsDirectoryPath string, fileExtension string) (*storage.ObjectHandle, error)
FindGcsFile finds a file in a GCS directory path for given file extension. File extension can be a file name as well. The lookup is done recursively.
func (*Client) FindGcsFileDepthLimited ¶
func (sc *Client) FindGcsFileDepthLimited(gcsDirectoryPath string, fileExtension string, lookupDepth int) (*storage.ObjectHandle, error)
FindGcsFileDepthLimited finds a file in a GCS directory path for given file extension up to lookupDepth deep. If lookup should be only for files directly in gcsDirectoryPath, lookupDepth should be set as 0. For recursive lookup with no limitations on depth, lookupDepth should be -1 File extension can be a file name as well.
func (*Client) GetBucket ¶
func (sc *Client) GetBucket(bucket string) *storage.BucketHandle
GetBucket returns a BucketHandle, which provides operations on the named bucket.
func (*Client) GetBucketAttrs ¶
func (sc *Client) GetBucketAttrs(bucket string) (*storage.BucketAttrs, error)
GetBucketAttrs returns bucket attributes for given bucket
func (*Client) GetGcsFileContent ¶
func (sc *Client) GetGcsFileContent(gcsObject *storage.ObjectHandle) ([]byte, error)
GetGcsFileContent returns content of a GCS object as byte array
func (*Client) GetObject ¶
func (sc *Client) GetObject(bucket string, objectPath string) domain.StorageObject
GetObject returns storage object for the given bucket and path
func (*Client) GetObjectAttrs ¶
GetObjectAttrs returns storage object attributes
func (*Client) GetObjects ¶
func (sc *Client) GetObjects(bucket string, objectPath string) domain.ObjectIteratorInterface
GetObjects returns object iterator for given bucket and path
func (*Client) UpdateBucket ¶
func (sc *Client) UpdateBucket( bucketName string, attrs storage.BucketAttrsToUpdate) error
UpdateBucket updates a GCS bucket
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient implements domain.HTTPClientInterface which abstracts HTTP functionality used by image import features.
type ObjectIterator ¶
type ObjectIterator struct {
// contains filtered or unexported fields
}
ObjectIterator is a wrapper around storage.ObjectIterator. Implements ObjectIteratorInterface.
func (*ObjectIterator) Next ¶
func (bi *ObjectIterator) Next() (*storage.ObjectAttrs, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns iterator.Done, all subsequent calls will return iterator.Done.
type ObjectIteratorCreator ¶
type ObjectIteratorCreator struct {
// contains filtered or unexported fields
}
ObjectIteratorCreator is responsible for creating GCS Object iterator
func (*ObjectIteratorCreator) CreateObjectIterator ¶
func (bic *ObjectIteratorCreator) CreateObjectIterator( bucket string, objectPath string) domain.ObjectIteratorInterface
CreateObjectIterator creates GCS Object iterator
type ResourceLocationRetriever ¶
type ResourceLocationRetriever struct { Mgce domain.MetadataGCEInterface ComputeGCEService daisyCompute.Client }
ResourceLocationRetriever is responsible for retrieving GCE zone to run import in
func NewResourceLocationRetriever ¶
func NewResourceLocationRetriever(aMgce domain.MetadataGCEInterface, cs daisyCompute.Client) *ResourceLocationRetriever
NewResourceLocationRetriever creates a ResourceLocationRetriever
func (*ResourceLocationRetriever) GetLargestStorageLocation ¶
func (rlr *ResourceLocationRetriever) GetLargestStorageLocation(storageLocation string) string
GetLargestStorageLocation returns the largest storage location that includes provided argument. If argument is a multi-region, the argument is returned. If argument is a region within a multi-region, the multi-region is returned. If argument is a region not within a multi-region, argument is returned.
func (*ResourceLocationRetriever) GetZone ¶
func (rlr *ResourceLocationRetriever) GetZone(storageLocation string, project string) (string, error)
GetZone retrieves GCE zone to run import in based on imported source file location and available zones in the project. If storageRegion is provided and valid, first zone within that region will be used. If no storageRegion is provided, GCE Zone from the running process will be used.
type ScratchBucketCreator ¶
type ScratchBucketCreator struct { StorageClient domain.StorageClientInterface Ctx context.Context BucketIteratorCreator domain.BucketIteratorCreatorInterface }
ScratchBucketCreator is responsible for creating Daisy scratch bucketets
func NewScratchBucketCreator ¶
func NewScratchBucketCreator(ctx context.Context, storageClient domain.StorageClientInterface) *ScratchBucketCreator
NewScratchBucketCreator creates a ScratchBucketCreator
func (*ScratchBucketCreator) CreateScratchBucket ¶
func (c *ScratchBucketCreator) CreateScratchBucket(sourceFileFlag string, project string, fallbackZone string, enableUniformBucketLevelAccess bool) (string, string, error)
CreateScratchBucket creates scratch bucket in the same region as sourceFileFlag. If failed to determine region by source file, we will try to determine region by fallbackZone. Returns (bucket_name, region, error)
func (*ScratchBucketCreator) IsBucketInProject ¶
func (c *ScratchBucketCreator) IsBucketInProject(project string, bucketName string) bool
IsBucketInProject checks if bucket belongs to a project
type TarGcsExtractor ¶
type TarGcsExtractor struct {
// contains filtered or unexported fields
}
TarGcsExtractor is responsible for extracting TAR archives from GCS to GCS
func NewTarGcsExtractor ¶
func NewTarGcsExtractor(ctx context.Context, sc domain.StorageClientInterface, logger logging.Logger) *TarGcsExtractor
NewTarGcsExtractor creates new TarGcsExtractor
func (*TarGcsExtractor) ExtractTarToGcs ¶
func (tge *TarGcsExtractor) ExtractTarToGcs(tarGcsPath string, destinationGcsPath string) error
ExtractTarToGcs extracts a tar file in GCS back into GCS directory