A Go utility to facilitate reading/writing files from/to Google Cloud Platform Storage.
This utility uses Google Application Credentials or GCP service accounts to connect to a Google Cloud Platform project and read/write files from/to Storage buckets.
This was written to provide GCP storage bucket functionality within auth. It wraps the Google provided Storage Go client.
The best place to start is with the tests. If running locally, then ensure that Google Application Credentials have been created. If running from a GCP virtual machine, then ensure that the relevant service account (compute, appengine etc.) has the following IAM scopes: 'Storage Object Viewer' and 'Storage Object Creator', or 'Storage Object Admin'. See GCP service accounts for further details.
See the tests for usage examples.
This utilises the following fine pieces of work:
Install with
$ go get -u github.com/lidstromberg/storage
You will also need to export (linux/macOS) or create (Windows) some environment variables.
Change LB_DEBUGON to true/false if you want verbose logging on/off. The other variables don't need to be changed.
################################
# STORAGE
################################
export STOR_DEBUGON='true'
export STOR_CLIPOOL='5'
################################
# GCP CREDENTIALS
################################
export GOOGLE_APPLICATION_CREDENTIALS="/PATH/TO/GCPCREDENTIALS.JSON"
(See Google Application Credentials)
File | Purpose |
---|---|
storage.go | Logic manager |
storage_test.go | Tests |
File | Purpose |
---|---|
config.go | Boot package parameters, environment var collection |
const.go | Package constants |
errors.go | Package error definitions |
env | Package environment variables for local/dev installation |
storagetester.json | test content file |
gogets | Statements for go-getting required packages |