README
¶
ejson2env
ejson2env is a tool to simplify storing secrets that should be accessible in the shell environment in your git repo. ejson2env is based on the ejson library and extends the ejson file format.
ejson2env exports all of the values in the environment object in the ejson file to the shell environment.
For example, with the below ejson file:
{
"_public_key": "<public key here>",
"environment": {
"SECRET_SHELL_VARIABLE": "<encrypted data>"
}
}
Running:
$ ejson test.ejson
Would result in the following output:
export SECRET_SHELL_VARIABLE=<decrypted data>
You can then have your shell evaluate this output:
$ eval $(ejson test.ejson)
Using ejson2env
ejson2env's usage information is described in it's included manual page.
Installing ejson2env
ejson2env is available through a number of different routes and package managers. If you plan on modifying ejson2env, it is suggested that you install via go get.
Go
ejson2env can be installed using the regular go get tool:
$ go get -u github.com/Shopify/ejson2env/cmd/ejson2env
You can then find the compiled binary in $GOPATH/bin
Debian Package
You can download the latest version of the Debian package from the releases page.
Install the downloaded package by calling:
$ dpkg -i ejson2env_1.0.3_amd64.deb
RubyGems
You can install ejson2env using Ruby's Gem tool:
$ gem install ejson2env
Homebrew
Provided your install of Homebrew is configured to pull from Shopify's Homebrew repo, you can install ejson2env by calling:
$ brew install ejson2env
Contributing
Releasing
The release process is somewhat awkward right now. ejson2env is released in three ways:
- rubygem;
.debpackage; and- homebrew formula.
Before releasing a new version, bump /VERSION, then run make, and commit the changes. Tag this
commit using git tag vx.y.z, e.g. v1.0.0.
In order to release the rubygem, find someone in the owners list at https://rubygems.org/gems/ejson2env and ask them to add you, then:
makegem push pkg/ejson2env-x.y.z.gem
To release the .deb package, edit the github release for the tag, and drop the pkg/*.deb in.
Releasing the homebrew package is more awkward. There is surely a more efficient way to do this but my process is:
dev clone homebrew-shopify- Edit
ejson2env.rb, changing the URL to reflect the new version. Also remove thebottle doparagraph. - Run
brew install ./ejson2env.rband change thesha256line to the SHA that is printed as an error. cd /usr/local/Homebrew/Library/Taps/shopify/homebrew-shopifycp $(dev project-path homebrew-shopify)/ejson2env.rb .brew install --build-bottle ejson2envbrew bottle ejson2env- This will generate a file called
ejson2env--vx.y.z.high_sierra.tar.gz. Rename it, turning--into-, e.g.ejson2env-vx.y.z.high_sierra.tar.gz. - Find some public place to upload this file. I use a personal S3 bucket but there are definitely better ways.
- reset your changes in the homebrew tap and
dev cd homeshop - Copy the
bottle doparagraph printed by thebrew bottlecommand intoejson2env.rb, and addroot_url "https://.... The final expected URL is going to be"#{root_url}/ejson2env...tar.gz. - Commit and push directly to master.
brew update && brew uninstall ejson2env && brew install ejson2env. If this didn't work, or didn't correctly install from the bottle (i.e. took more than 10 seconds to install), troubleshoot, or revert.