From fcffdc47673e21074d0f3a515dc661c5feb03ffb Mon Sep 17 00:00:00 2001 From: Josh Komoroske Date: Fri, 23 Feb 2018 18:16:15 -0800 Subject: [PATCH] Load PLUGIN_ENV_FILE before app is run --- main.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index 096aba0..694264b 100644 --- a/main.go +++ b/main.go @@ -21,6 +21,11 @@ func main() { Version = fmt.Sprintf("1.3.1+%s", build) } + // Load env-file if it exists first + if filename, found := os.LookupEnv("PLUGIN_ENV_FILE"); found { + _ = godotenv.Load(filename) + } + app := cli.NewApp() app.Name = "Drone SSH" app.Usage = "Executing remote ssh commands" @@ -87,10 +92,6 @@ func main() { Usage: "execute commands", EnvVar: "PLUGIN_SCRIPT,SSH_SCRIPT", }, - cli.StringFlag{ - Name: "env-file", - Usage: "source env file", - }, cli.StringFlag{ Name: "proxy.ssh-key", Usage: "private ssh key of proxy", @@ -185,10 +186,6 @@ REPOSITORY: } func run(c *cli.Context) error { - if c.String("env-file") != "" { - _ = godotenv.Load(c.String("env-file")) - } - plugin := Plugin{ Config: Config{ Key: c.String("ssh-key"),