Load PLUGIN_ENV_FILE before app is run (#112)

This commit is contained in:
Josh Komoroske 2018-02-24 03:47:07 -08:00 committed by Bo-Yi Wu
parent 84cb184039
commit f92f762c9d

13
main.go
View File

@ -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"),