https://github.com/cloudfoundry/bosh-gcscli
GCS for BOSH
https://github.com/cloudfoundry/bosh-gcscli
bosh
Last synced: about 1 year ago
JSON representation
GCS for BOSH
- Host: GitHub
- URL: https://github.com/cloudfoundry/bosh-gcscli
- Owner: cloudfoundry
- License: apache-2.0
- Created: 2017-05-23T22:41:55.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2024-09-14T10:18:02.000Z (over 1 year ago)
- Last Synced: 2024-09-14T20:41:09.254Z (over 1 year ago)
- Topics: bosh
- Language: Go
- Size: 19.1 MB
- Stars: 4
- Watchers: 33
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
## bosh-gcscli
[](https://godoc.org/github.com/cloudfoundry/bosh-gcscli)
A Golang CLI for uploading, fetching and deleting content to/from [Google Cloud Storage](https://cloud.google.com/storage/).
This tool exists to work with the [bosh-cli](https://github.com/cloudfoundry/bosh-cli) and [director](https://github.com/cloudfoundry/bosh).
This is **not** an official Google Product.
## Installation
```bash
go get github.com/cloudfoundry/bosh-gcscli
```
## Commands
### Usage
```bash
bosh-gcscli --help
```
### Upload an object
```bash
bosh-gcscli -c config.json put
```
### Fetch an object
```bash
bosh-gcscli -c config.json get
```
### Delete an object
```bash
bosh-gcscli -c config.json delete
```
### Check if an object exists
```bash
bosh-gcscli -c config.json exists
```
### Generate a signed url for an object
If there is an encryption key present in the config, then an additional header is sent
```bash
bosh-gcscli -c config.json sign
```
Where:
- `` is GET, PUT, or DELETE
- `` is a duration string less than 7 days (e.g. "6h")
## Configuration
The command line tool expects a JSON configuration file. Run `bosh-gcscli --help` for details.
### Authentication Methods (`credentials_source`)
* `static`: A [service account](https://cloud.google.com/iam/docs/creating-managing-service-account-keys) key will be provided via the `json_key` field.
* `none`: No credentials are provided. The client is reading from a public bucket.
* <empty>: [Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials)
will be used if they exist (either through `gcloud auth application-default login` or a [service account](https://cloud.google.com/iam/docs/understanding-service-accounts)).
If they don't exist the client will fall back to `none` behavior.
## Running Integration Tests
1. Ensure [gcloud](https://cloud.google.com/sdk/downloads) is installed and you have authenticated (`gcloud auth login`).
These credentials will be used by the Makefile to create/destroy Google Cloud Storage buckets for testing.
1. Set the Google Cloud project: `gcloud config set project `
1. Generate a service account with the `Storage Admin` role for your project and set the contents as
the environment variable `GOOGLE_APPLICATION_CREDENTIALS`, for example:
```bash
export project_id=$(gcloud config get-value project)
export service_account_name=bosh-gcscli-integration-tests
export service_account_email=${service_account_name}@${project_id}.iam.gserviceaccount.com
credentials_file=$(mktemp)
gcloud config set project ${project_id}
gcloud iam service-accounts create ${service_account_name} --display-name "Integration Test Access for bosh-gcscli"
gcloud iam service-accounts keys create ${credentials_file} --iam-account ${service_account_email}
gcloud project add-iam-policy-binding ${project_id} --member serviceAccount:${service_account_email} --role roles/storage.admin
export GOOGLE_SERVICE_ACCOUNT="$(cat ${credentials_file})"
export GOOGLE_APPLICATION_CREDENTIALS="$(cat ${credentials_file})"
export LC_ALL=C # fix `tr` complaining about "illegal byte sequence" on OSX
```
1. Run the unit and fast integration tests: `make test-fast-int`
1. Clean up buckets: `make clean-gcs`
## Development
* A Makefile is provided that automates integration testing. Try `make help` to get started.
* [gvt](https://godoc.org/github.com/FiloSottile/gvt) is used for vendoring.
## Contributing
For details on how to contribute to this project - including filing bug reports and contributing code changes - please see [CONTRIBUTING.md](./CONTRIBUTING.md).
## License
This tool is licensed under Apache 2.0. Full license text is available in [LICENSE](LICENSE).