mirror of
https://github.com/Luzifer/envrun.git
synced 2024-12-20 18:31:17 +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"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
openssl "github.com/Luzifer/go-openssl"
|
||||||
"github.com/Luzifer/rconfig"
|
"github.com/Luzifer/rconfig"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,6 +17,7 @@ var (
|
||||||
EnvFile string `flag:"env-file" default:".env" description:"Location of the environment file"`
|
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"`
|
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"`
|
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)
|
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
|
var childenv map[string]string
|
||||||
if cfg.CleanEnv {
|
if cfg.CleanEnv {
|
||||||
childenv = map[string]string{}
|
childenv = map[string]string{}
|
||||||
|
|
Loading…
Reference in a new issue