From 42f3239f4577792d7753b8cf1bb0573999311a2e Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Mon, 25 Jun 2018 14:10:25 -0700 Subject: [PATCH] Adds check for required environment variables --- cmd/root.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/root.go b/cmd/root.go index db3f6bf..0284f38 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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) @@ -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)