lighthouse/lighthouse — pull request #21 by cmbrose (2014-11-21 07:45:15+00:00)
Title: Provider adding

So this one is a bit of a doozy...

**Primary additions**
1. Hostname aliasing
2. Permissions for Docker requests

**API additions**
`GET /api/v0.1/users/permissions/vms`
- lists the IP address of all Docker instances the current user can access (i.e. those that won't be blocked)

**Why this is *so* massive**
1. Added a postgres package to ease database work:
- storage here is in key-value pairs where key is a string and value is anything (it's turned into JSON)
- all keys are unique (such as emails)
- database_testing_utils.go helps mock database calls to lighten dependencies in unit tests

2. Added session package in order to:
- make auth fields (like email) available everywhere without worrying about circular dependencies
- allow us to store non-auth values

3. User class moved to its own package so that everything can access it

**Testing**
Testing for non-Docker endpoints can be done as usual.

With aliasing, we have to do a little work to make Docker listen to us:
`docker -H 0.0.0.0:5001 -H unix:///var/run/docker.sock -d &`
This makes the docker daemon listen on port 5001 as well as its usual socket.

Then find Docker's IP using `ifconfig`. It should default to `172.17.42.1`, but if not you will need to change this value in `config/permissions.json`.

Now you're ready to make requests!!

The alias of the local Docker instance is `boot2docker`, so the request format is:
`localhost:5000/api/v0.1/boot2docker/d/{DOCKER_REQUEST}`