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 Storage
- func (s *Storage) Catalog(ctx context.Context, token string, pageSize int) ([]paths.AllPathParams, string, 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) SetStaleThreshold(threshold time.Duration)
- func (s *Storage) Zip(ctx context.Context, module, version string) (pkgstorage.SizeReadCloser, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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) Catalog ¶ added in v0.3.0
func (s *Storage) Catalog(ctx context.Context, token string, pageSize int) ([]paths.AllPathParams, string, error)
Catalog implements the (./pkg/storage).Catalog interface It returns a list of versions, if any, for a given module.
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 accessible in the storage bucket as per an ACL rule.
func (*Storage) SetStaleThreshold ¶ added in v0.14.1
SetStaleThreshold sets the threshold of how long we consider a lock metadata stale after.
func (*Storage) Zip ¶ added in v0.1.0
func (s *Storage) Zip(ctx context.Context, module, version string) (pkgstorage.SizeReadCloser, error)
Zip implements Getter.