After reading Dan's post
about cf shell helper
last Friday, I was inspired. Actually, I became a bit obsessed by the idea of switching Cloud Foundry environments. On a daily basis I work across 3 instances of Cloud Foundry, in at least 5 different spaces so running cf api
, cf login
, and cf target
, is a way of life and not one I'm particularly fond of. Immediately upon seeing his work, I recognized how similar it was to another tool I use on a daily basis, rbenv
. So this weekend I forked rbenv
, created cfenv
, and am happy to announce it today.
is a way of managing multiple Cloud Foundry environments simultaneously, using a series of CF_HOME
directories. It allows you to choose the Cloud Foundry environment at a global level (using a ~/.cfenv/environment
file), at a project level (using a .cf-environment
file), or in a particular shell (using a CFENV_ENVIRONMENT
environment variable). An example of how I might use cfenv
Suffice it to say, if you're familiar with how rbenv works, you'll feel right at home with cfenv. Please see the installation instructions for how to install it (and its close relative cf-build), but for OS X Homebrew users, TL;DR:
- Most of the day I spend pushing to my own development environment. Therefore I've run cfenv global development to ensure that by default I use api.run.pivotal.io/bhale/development.
- Whenever I work on the java-buildpack-system-tests I want to push to our system test environment. Therefore, I've gone into that project's directory and run cfenv local system-test to ensure that I always push into api.run.pivotal.io/jbp-test/system-test.
- Occasionally I need to push to a copy of Cloud Foundry installed using bosh-lite to test offline buildpack behavior. When that happens I run cfenv shell bosh-lite to ensure that I push to api.10.244.0.34.xip.io/admin/admin without affecting any other shells.
$ brew tap nebhale/personal
$ brew install cfenv cf-build
$ echo 'eval "$(cfenv init -)"' >> ~/.bash_profile
$ source ~/.bash_profile
$ cfenv create development
$ cfenv global development
$ cf login
Please note that this project is not, in any way, associated with Pivotal or my day job working on the Cloud Foundry Java Experience; this is just something I've put together, and will be supporting, in my spare time.
Once again, a huge thanks goes out to Dan Mikusa for highlighting the issue and a possible path to solving it. Hope you guys find cfenv as useful as I do.