Documentation ¶
Index ¶
- Constants
- Variables
- type APIStore
- type GcsFS
- func (g *GcsFS) Client() interface{}
- func (g *GcsFS) Copy(ctx context.Context, src, des cloudstorage.Object) error
- func (g *GcsFS) Delete(ctx context.Context, obj string) error
- func (g *GcsFS) Folders(ctx context.Context, csq cloudstorage.Query) ([]string, error)
- func (g *GcsFS) Get(ctx context.Context, objectpath string) (cloudstorage.Object, error)
- func (g *GcsFS) List(ctx context.Context, csq cloudstorage.Query) (*cloudstorage.ObjectsResponse, error)
- func (g *GcsFS) Move(ctx context.Context, src, des cloudstorage.Object) error
- func (g *GcsFS) NewObject(objectname string) (cloudstorage.Object, error)
- func (g *GcsFS) NewReader(o string) (io.ReadCloser, error)
- func (g *GcsFS) NewReaderWithContext(ctx context.Context, o string) (io.ReadCloser, error)
- func (g *GcsFS) NewWriter(o string, metadata map[string]string) (io.WriteCloser, error)
- func (g *GcsFS) NewWriterWithContext(ctx context.Context, o string, metadata map[string]string) (io.WriteCloser, error)
- func (g *GcsFS) Objects(ctx context.Context, csq cloudstorage.Query) (cloudstorage.ObjectIterator, error)
- func (g *GcsFS) String() string
- func (g *GcsFS) Type() string
- type GoogleOAuthClient
- func BuildDefaultGoogleTransporter(scope ...string) (GoogleOAuthClient, error)
- func BuildGCEMetadatTransporter(serviceAccount string) (GoogleOAuthClient, error)
- func BuildGoogleFileJWTTransporter(keyPath string, scope string) (GoogleOAuthClient, error)
- func BuildGoogleJWTTransporter(jwtConf *cloudstorage.JwtConf) (GoogleOAuthClient, error)
- func NewGoogleClient(conf *cloudstorage.Config) (client GoogleOAuthClient, err error)
Constants ¶
const ( // AuthJWTKeySource is for a complete string representing json of JWT AuthJWTKeySource cloudstorage.AuthMethod = "LyticsJWTkey" // AuthGoogleJWTKeySource is a string representing path to a file of JWT AuthGoogleJWTKeySource cloudstorage.AuthMethod = "GoogleJWTFile" // AuthGCEMetaKeySource is flag saying to use gcemetadata AuthGCEMetaKeySource cloudstorage.AuthMethod = "gcemetadata" // AuthGCEDefaultOAuthToken means use local auth where it (google client) // checks variety of locations for local auth tokens. AuthGCEDefaultOAuthToken cloudstorage.AuthMethod = "gcedefaulttoken" )
const StoreType = "gcs"
StoreType = "gcs"
Variables ¶
var ( // GCSRetries number of times to retry for GCS. GCSRetries int = 55 )
Functions ¶
This section is empty.
Types ¶
type APIStore ¶
type APIStore struct {
// contains filtered or unexported fields
}
APIStore a google api store
func NewAPIStore ¶
func NewAPIStore(conf *cloudstorage.Config) (*APIStore, error)
NewAPIStore create api store.
func (*APIStore) BucketExists ¶
BucketExists checks for the bucket name
func (*APIStore) CreateBucket ¶
CreateBucket creates a new bucket in GCS
type GcsFS ¶
GcsFS Simple wrapper for accessing smaller GCS files, it doesn't currently implement a Reader/Writer interface so not useful for stream reading of large files yet.
func NewGCSStore ¶
NewGCSStore Create Google Cloud Storage Store.
func (*GcsFS) Client ¶
func (g *GcsFS) Client() interface{}
Client gets access to the underlying google cloud storage client.
func (*GcsFS) List ¶
func (g *GcsFS) List(ctx context.Context, csq cloudstorage.Query) (*cloudstorage.ObjectsResponse, error)
Objects returns an iterator over the objects in the google bucket that match the Query q. If q is nil, no filtering is done.
func (*GcsFS) NewObject ¶
func (g *GcsFS) NewObject(objectname string) (cloudstorage.Object, error)
NewObject of Type GCS.
func (*GcsFS) NewReader ¶
func (g *GcsFS) NewReader(o string) (io.ReadCloser, error)
NewReader create GCS file reader.
func (*GcsFS) NewReaderWithContext ¶
NewReaderWithContext create new GCS File reader with context.
func (*GcsFS) NewWriterWithContext ¶
func (g *GcsFS) NewWriterWithContext(ctx context.Context, o string, metadata map[string]string) (io.WriteCloser, error)
NewWriterWithContext create writer with provided context and metadata.
func (*GcsFS) Objects ¶
func (g *GcsFS) Objects(ctx context.Context, csq cloudstorage.Query) (cloudstorage.ObjectIterator, error)
Objects returns an iterator over the objects in the google bucket that match the Query q. If q is nil, no filtering is done.
type GoogleOAuthClient ¶
GoogleOAuthClient An interface so we can return any of the 3 Google transporter wrapper as a single interface.
func BuildDefaultGoogleTransporter ¶
func BuildDefaultGoogleTransporter(scope ...string) (GoogleOAuthClient, error)
BuildDefaultGoogleTransporter builds a transpoter that wraps the google DefaultClient:
Ref https://github.com/golang/oauth2/blob/master/google/default.go#L33
DefaultClient returns an HTTP Client that uses the DefaultTokenSource to obtain authentication credentials
Ref : https://github.com/golang/oauth2/blob/master/google/default.go#L41
DefaultTokenSource is a token source that uses "Application Default Credentials".
It looks for credentials in the following places, preferring the first location found:
- A JSON file whose path is specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable.
- A JSON file in a location known to the gcloud command-line tool. On other systems, $HOME/.config/gcloud/credentials.
- On Google App Engine it uses the appengine.AccessToken function.
- On Google Compute Engine, it fetches credentials from the metadata server. (In this final case any provided scopes are ignored.)
For more details, see: https://developers.google.com/accounts/docs/application-default-credentials
Samples of possible scopes: Google Cloud Storage : https://github.com/GoogleCloudPlatform/gcloud-golang/blob/69098363d921fa3cf80f930468a41a33edd9ccb9/storage/storage.go#L51 BigQuery : https://github.com/GoogleCloudPlatform/gcloud-golang/blob/522a8ceb4bb83c2def27baccf31d646bce11a4b2/bigquery/bigquery.go#L52
func BuildGCEMetadatTransporter ¶
func BuildGCEMetadatTransporter(serviceAccount string) (GoogleOAuthClient, error)
The account may be empty or the string "default" to use the instance's main account.
func BuildGoogleFileJWTTransporter ¶
func BuildGoogleFileJWTTransporter(keyPath string, scope string) (GoogleOAuthClient, error)
BuildGoogleFileJWTTransporter Build a Google Storage Client from a path to a json file that has JWT.
func BuildGoogleJWTTransporter ¶
func BuildGoogleJWTTransporter(jwtConf *cloudstorage.JwtConf) (GoogleOAuthClient, error)
BuildGoogleJWTTransporter create a GoogleOAuthClient from jwt config.
func NewGoogleClient ¶
func NewGoogleClient(conf *cloudstorage.Config) (client GoogleOAuthClient, err error)
NewGoogleClient create new Google Storage Client.