Giter VIP home page Giter VIP logo

cf-env's Introduction

Display Cloud Foundry environment variables

A simple Sinatra application. Once deployed to Cloud Foundry, it will echo the Environment and HTTP Request Headers.

This is especially useful to learn about service connection details ($VCAP_SERVICES) being passed to an application. Create them, bind them to this running application, and you'll see the nested JSON string that is set in $VCAP_SERVICES.

Deploy

The repo contains a manifest file which creates a new application called cfenv, with a random string in the URL to avoid collisions.

To deploy:

$ cf push
Using manifest file manifest.yml

Creating cfenv... OK

Creating route cfenv-dfe2f.cfapps.io... OK
Binding cfenv-dfe2f.cfapps.io to cfenv... OK
Uploading cfenv... OK
Starting cfenv... OK
-----> Downloaded app package (64K)
-----> Using Ruby version: ruby-1.9.3
-----> Installing dependencies using Bundler version 1.3.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
       Fetching gem metadata from https://rubygems.org/..........
       Fetching gem metadata from https://rubygems.org/..
       Installing json_pure (1.8.0)
       Installing rack (1.5.2)
       Installing rack-protection (1.5.0)
       Installing tilt (1.4.1)
       Installing sinatra (1.4.3)
       Using bundler (1.3.2)
       Your bundle is complete! It was installed into ./vendor/bundle
       Cleaning up the bundler cache.
-----> Uploading droplet (24M)
Checking cfenv...
Staging in progress...
Staging in progress...
Staging in progress...
  1/1 instances: 1 running
OK
$ open http://cfenv-dfe2f.cfapps.io

Env Var API

To view a specific environment variable, you can use the /v1/:var endpoint:

$ curl http://cfenv-dfe2f.cfapps.io/v1/CF_INSTANCE_PORTS
[{"external":60148,"internal":8080},{"external":60149,"internal":2222}]

For envrionment variables that contain JSON data, you can grab individual values out of them as well (values are re-encoded to JSON):

$ curl http://cfenv-dfe2f.cfapps.io/v1/CF_INSTANCE_PORTS/0
{"external":60148,"internal":8080}
$ curl http://cfenv-dfe2f.cfapps.io/v1/CF_INSTANCE_PORTS/0/internal
8080

cf-env's People

Contributors

andypiper avatar cweibel avatar drnic avatar geofffranks avatar jhunt avatar lnguyen avatar naveedahd avatar rkoster avatar svaiyapu avatar xiujiao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.