An example Heroku addon written in Golang
Heroku gives a ton of documentation throughout their site, but I couldn't find a good end-to-end example of creating a custom Heroku addon that can then be published into their Marketplace. I wanted this to cover all parts of the addon from the provisioning and SSO endpoints to the actual table creation and database model.
- Using a PostgreSQL database as a datastore (Install Postgres locally)
- The ENVs in this are just used as an example, real world you'd probably use a vault or store them only on the deployed environment
There are 3 tables created as part of this: plans
, users
, and apps
. The assumption is that a User can have many apps or in Heroku terms this would be a single Heroku user could SSO once into this addon application and have access to their various Heroku associated apps.
brew install glide
createdb addon
sql-migrate up
make
make run
This is a complete example. I still have some additional tests to write, but it currently passes the Addon spec. This has been tested against the kensa gem. Travis executes the following commands after inserting the test data. Prerequisites to running the kensa tests
gem install kensa
cat db/test_seeds/*.sql | psql addon
Then run the following commands
kensa test
kensa test sso 123
Or the test script (which does all of them for you)
./bin/test.sh