mirror of
https://github.com/Luzifer/envrun.git
synced 2024-11-08 14:20:01 +00:00
Add support for encrypted env files
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
2f3434c1ac
commit
8c18fc278f
1 changed files with 8 additions and 0 deletions
8
main.go
8
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{}
|
||||
|
|
Loading…
Reference in a new issue