Vault::Tools
Tools is the English word for ツール. Tooling for the Heroku Vault team to enable faster bootstrapping for Ruby projects.
Installation
Add this line to your application's Gemfile:
gem 'vault-tools'
Usage
Vault.setup
calling Vault.setup will:
- call
Bundler.requirewith the correspondingRACK_ENV - add
./libto the$LOAD_PATH - set
TZto utc as well asSequel's default timezone - overwrite
Time.to_sto default to ISO8601 - replace Ruby's default, deprecated
ConfigwithVault::Config - if the
CONFIG_APPenvironment variable is defined and this is the production environment, it will attempt to use the Heroku API to load the config vars from another app intoVault::Config - enable distributed tracing via Zipkin, if the required config vars are set
Vault::Config
Provides a better way to configure the application than simply pulling
strings from ENV.
defaults
Config[:foo]
# => nil
Config.default(:foo, 'bar')
Config[:foo]
# => 'bar'
Config['FOO']
# => 'bar'
type casts
Returns nil when undefined, otherwise casts to indicated type.
Config.int(:max_connections)
Vault::Log
Log.time(name, t)
# => "measure=true at=web-40"
Log.count('foo')
# => "measure=true at=foo"
Vault::Web
Sinatra base class
Includes request logging and health endpoints
class Web < Vault::Web
helpers Vault::SinatraHelpers::HtmlSerializer
end
Setting up a development environment
Install the dependencies:
bundle install --binstubs vendor/bin
rbenv rehash
Run the tests:
vendor/bin/t
Generate the API documentation:
vendor/bin/d
Configs for tracing
The following are config vars to be set in the consumer app for tracing with Zipkin:
APP_NAME(required) what the trace will show up as in the Zipkin interface.ZIPKIN_ENABLED(required) must be set totrueto start tracing.ZIPKIN_API_HOST(required) where to post traces to. URL must contain the basic auth creds from the Tools team.ZIPKIN_SAMPLE_RATEdefaults to0.1.
Releasing
> bundle exec rake release
