Skip to content

Commit

Permalink
Adds check for required environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Hamilton committed Jun 25, 2018
1 parent b4f5ec0 commit 42f3239
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ var rootCmd = &cobra.Command{

switch directoryBackend {
case "github":
if os.Getenv("GITHUB_TOKEN") == "" {
errorAndExit(errors.New("You must set the GITHUB_TOKEN environment variable"), 1)
}
dirState, err = directory.NewGitHub(Org)
if err != nil {
errorAndExit(fmt.Errorf("unable to get directory client: %+v", err), 1)
Expand All @@ -49,6 +52,9 @@ var rootCmd = &cobra.Command{

switch storageBackend {
case "vault":
if os.Getenv("VAULT_TOKEN") == "" {
errorAndExit(errors.New("You must set the VAULT_TOKEN environment variable with a valid Vault token"), 1)
}
storageClient, err = storage.NewVault()
if err != nil {
errorAndExit(fmt.Errorf("unable to get storage client: %+v", err), 1)
Expand Down

0 comments on commit 42f3239

Please sign in to comment.