Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Managing Passwords and Sensitive information with rbenv-vars #4

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ that supports plugin bundles.)

## Usage

### Variable File

Define environment variables in an `.rbenv-vars` file in your project,
one variable per line, in the format `VAR=value`. For example:

Expand All @@ -40,6 +42,26 @@ directories of the current directory will be set. Variables from the
Use the `rbenv vars` command to print all environment variables in the
order they'll be set.

### Alternate Variable File

It is a good idea to segregate passwords and sensitive information from
your public code repository. To help with this, an alternate file can
be used with the filename `.rbenv-vars-<yourfile>`. The alternate file
will be loaded before the normal `.rbenv-vars` file.

For example, your application may require an environment variable with
a database connect string that contains a password.

Alternate file: `.rbenv-vars-passwords`

DB_PASSWORD=mypassword

Normal file: `.rbenv-vars`

DB_CONNECT_STRING=postgres://dbuser:${DB_PASSWORD}@localhost/my_database

In this situation, you would .gitignore the `.rbenv-vars-passwords` file.

## License

&copy; 2011 Sam Stephenson. Released under the MIT license. See
Expand Down
4 changes: 4 additions & 0 deletions bin/rbenv-vars
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ find-rbenv-vars-files() {

local root="$RBENV_DIR"
local results=""
shopt -s nullglob # suppress stderr output if glob doesn't match

while [ -n "$root" ]; do
if [ -e "${root}/.rbenv-vars" ]; then
results="${root}/.rbenv-vars"$'\n'"$results"
fi
for f in ${root}/.rbenv-vars-* ; do
results="$f"$'\n'"$results" # include alternate file in results list
done
root="${root%/*}"
done

Expand Down