From 8c18fc278f02b479a6485fb564949f8c47e9bb28 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Tue, 21 Mar 2017 14:54:59 +0100 Subject: [PATCH] Add support for encrypted env files Signed-off-by: Knut Ahlers --- main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.go b/main.go index 53cf3aa..6a63b31 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "os/exec" "strings" + openssl "github.com/Luzifer/go-openssl" "github.com/Luzifer/rconfig" ) @@ -16,6 +17,7 @@ var ( EnvFile string `flag:"env-file" default:".env" description:"Location of the environment file"` Silent bool `flag:"q" default:"false" description:"Suppress informational messages from envrun"` CleanEnv bool `flag:"clean" default:"false" description:"Do not pass current environment to child process"` + Password string `flag:"password,p" default:"" env:"PASSWORD" description:"Password to decrypt environment file"` }{} ) @@ -56,6 +58,12 @@ func main() { log.Fatalf("Could not read env-file: %s", err) } + if cfg.Password != "" { + if body, err = openssl.New().DecryptString(cfg.Password, string(body)); err != nil { + log.Fatalf("Could not decrypt env-file: %s", err) + } + } + var childenv map[string]string if cfg.CleanEnv { childenv = map[string]string{}