Skip to content
Permalink
Browse files

Allow ENV-var to override token

Heroku appears to pass secrets via environment variables. In this
example TOKEN is used.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
  • Loading branch information
alexellis committed Nov 24, 2019
1 parent 5333811 commit c2033ecaaef9381d975a3fcadb86011056865fb9
Showing with 5 additions and 0 deletions.
  1. +5 −0 cmd/server.go
@@ -68,6 +68,11 @@ func runServer(cmd *cobra.Command, _ []string) error {
token = tokenVal
}

if tokenEnv, ok := os.LookupEnv("TOKEN"); ok && len(tokenEnv) > 0 {
fmt.Printf("Token read from environment variable.\n")
token = tokenEnv
}

printToken, err := cmd.Flags().GetBool("print-token")
if err != nil {
return errors.Wrap(err, "failed to get 'print-token' value.")

0 comments on commit c2033ec

Please sign in to comment.
You can’t perform that action at this time.