1
0
mirror of https://github.com/Luzifer/envrun.git synced 2024-09-19 15:42:58 +00:00

Add support for encrypted env files

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2017-03-21 14:54:59 +01:00
parent 2f3434c1ac
commit 8c18fc278f
Signed by: luzifer
GPG Key ID: DC2729FDD34BE99E

View File

@ -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{}