https://github.com/cloudfoundry-community/vcap-squash
Turn VCAP_SERVICES into flat env vars
https://github.com/cloudfoundry-community/vcap-squash
cli-utilities cloud-foundry environment-variables golang
Last synced: 9 months ago
JSON representation
Turn VCAP_SERVICES into flat env vars
- Host: GitHub
- URL: https://github.com/cloudfoundry-community/vcap-squash
- Owner: cloudfoundry-community
- License: mit
- Created: 2016-05-13T23:19:29.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-06-04T02:06:37.000Z (about 10 years ago)
- Last Synced: 2024-06-20T17:35:11.216Z (about 2 years ago)
- Topics: cli-utilities, cloud-foundry, environment-variables, golang
- Language: Go
- Size: 10.7 KB
- Stars: 7
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vcap-squash [](https://travis-ci.org/cloudfoundry-community/vcap-squash)
Turn VCAP_SERVICES into flat env vars
## Download
Visit the [releases](https://github.com/cloudfoundry-community/vcap-squash/releases/latest) page
and download the binary for your system
## Usage
This application will parse the `VCAP_SERVICES` environment variable and output the unix exports of the flattened version.
Flattened vcap environment variables start with the service name and append `_` for each nested credential.
For example:
```sh
$ VCAP_SERVICES='{ "user-provided": [ {
"name": "myservice",
"credentials": {
"url": "myservice.com",
"username": "josh",
"password": "secret",
"nested": {
"key": "value",
"number": 123
}
}
} ] }' ./vcap-squash
export MYSERVICE_URL="myservice.com"
export MYSERVICE_USERNAME="josh"
export MYSERVICE_PASSWORD="secret"
export MYSERVICE_NESTED_KEY="value"
export MYSERVICE_NESTED_NUMBER=123
```
To set your environment variables using this output, use
```sh
eval "$(./vcap-squash)"
```
### In Cloud Foundry
Add the proper `vcap-squash` binary to your project root (depending on cf stack)
Create a `.profile.d/setenv.sh` file to push along with your repo
```sh
#!/bin/sh
eval $(./vcap-squash)
```
## Development
To run all basic tasks, use
```sh
$ make
```
### Dependencies
To download needed libraries:
```sh
$ make deps
```
### Test
To run the test suite, use
```sh
$ make test
```
Run the test suite in development/watch mode:
```sh
$ make watch
```
### Build local
To build a binary using your go env:
```sh
$ make build-local
```
### Build all
Build the binary for all systems:
```sh
$ make build
```
_the binaries will be placed in `./out`_