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

Display all required environment variables #2

Open
albrow opened this issue Sep 29, 2015 · 2 comments
Open

Display all required environment variables #2

albrow opened this issue Sep 29, 2015 · 2 comments

Comments

@albrow
Copy link

albrow commented Sep 29, 2015

See https://github.com/plaid/style/pull/37 for a background.

I believe there are two things we should do to make environment variables more pleasant to work with.

  1. We should add a --help flag to all service executables which prints out the required environment variables, and optionally some other information about the service.
  2. When you forget a required env var, all required env vars should be printed out, not just the one you forgot. This will reduce time to get up and running and eliminate the cycle of add the env var, run the service, add another env var, run it again, etc. It might make sense to just print the help text in this case.
@davidchambers
Copy link
Contributor

We could provide a new function which takes and returns a mapping, or report all failures.

var GITHUB_API_TOKEN = envvar.string('GITHUB_API_TOKEN');
var HTTP_MAX_SOCKETS = envvar.number('HTTP_MAX_SOCKETS');
var ENABLE_FEATURE_X = envvar.boolean('ENABLE_FEATURE_X', false);

The above could then be written:

//  env :: { GITHUB_API_TOKEN :: String
//         , HTTP_MAX_SOCKETS :: Number
//         , ENABLE_FEATURE_X :: Boolean
//         }
var env = envvar.extract({
  GITHUB_API_TOKEN: {type: 'string'},
  HTTP_MAX_SOCKETS: {type: 'number'},
  ENABLE_FEATURE_X: {type: 'boolean', default: false},
});

The mapping provided to envvar.extract could be defined in a JSON file, and could contain additional properties. This JSON file could then be used to generate --help text. Actually generating this text is likely out of scope for this project, as the formatting would depend on the tool being used to generate the rest of the string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@davidchambers @albrow and others