Documentation
¶
Overview ¶
Package gcp provides a storage driver to upload module files to a google cloud platform storage bucket.
Configuration ¶
Environment variables:
ATHENS_STORAGE_GCP_BUCKET // full name of storage bucket ATHENS_STORAGE_GCP_SA // path to json keyfile of a service account
Example:
Bash: export ATHENS_STORAGE_GCP_BUCKET="fancy-pony-33928.appspot.com" Fish: set -x ATHENS_STORAGE_GCP_BUCKET fancy-pony-339288.appspot.com
Index ¶
- type Bucket
- type Storage
- func (s *Storage) Close() error
- func (s *Storage) Delete(ctx context.Context, module, version string) error
- func (s *Storage) Exists(ctx context.Context, module, version string) (bool, error)
- func (s *Storage) GoMod(ctx context.Context, module, version string) ([]byte, error)
- func (s *Storage) Info(ctx context.Context, module, version string) ([]byte, error)
- func (s *Storage) List(ctx context.Context, module string) ([]string, error)
- func (s *Storage) Save(ctx context.Context, module, version string, mod []byte, zip io.Reader, ...) error
- func (s *Storage) Zip(ctx context.Context, module, version string) (io.ReadCloser, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket interface {
// Delete removes the file
Delete(ctx context.Context, path string) error
// Open returns a reader for a path and any error
Open(ctx context.Context, path string) (io.ReadCloser, error)
// Write returns a new writer for a path
// This writer will overwrite any existing file stored at the same path
Write(ctx context.Context, path string) io.WriteCloser
// List returns a slice of paths for a prefix and any error
List(ctx context.Context, prefix string) ([]string, error)
// Exists returns true if the file exists
Exists(ctx context.Context, path string) (bool, error)
}
Bucket provides file operations for a Google Cloud Storage resource.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage implements the (./pkg/storage).Backend interface
func New ¶ added in v0.1.0
New returns a new Storage instance backed by a Google Cloud Storage bucket. The bucket name to be used will be loaded from the environment variable ATHENS_STORAGE_GCP_BUCKET.
If you're not running on GCP, set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the path of your service account file. If you're running on GCP (e.g. AppEngine), credentials will be automatically provided. See https://cloud.google.com/docs/authentication/getting-started.
func (*Storage) Close ¶
Close calls the underlying storage client's close method It is not required to be called on program exit but provided here for completness.
func (*Storage) Delete ¶
Delete implements the (./pkg/storage).Deleter interface and removes a version of a module from storage. Returning ErrNotFound if the version does not exist.
func (*Storage) Exists ¶
Exists implements the (./pkg/storage).Checker interface returning true if the module at version exists in storage
func (*Storage) List ¶
List implements the (./pkg/storage).Lister interface It returns a list of versions, if any, for a given module
func (*Storage) Save ¶
func (s *Storage) Save(ctx context.Context, module, version string, mod []byte, zip io.Reader, info []byte) error
Save uploads the module's .mod, .zip and .info files for a given version It expects a context, which can be provided using context.Background from the standard library until context has been threaded down the stack. see issue: https://github.com/gomods/athens/issues/174
Uploaded files are publicly accessable in the storage bucket as per an ACL rule.