From cb765bef60e273b7d32c0a84ffff232139ebba0e Mon Sep 17 00:00:00 2001 From: Jacob McCann Date: Thu, 27 Oct 2016 16:42:45 -0500 Subject: [PATCH] Load PLUGIN_ENV_FILE before app --- .drone.yml | 1 + main.go | 13 +++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.drone.yml b/.drone.yml index 668fa8f..f63cb3b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,5 +1,6 @@ workspace: base: /go + path: src/github.com/drone-plugins/drone-docker pipeline: test: diff --git a/main.go b/main.go index 9145cbf..f8fe05b 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,11 @@ import ( var build = "0" // build number set at compile-time func main() { + // Load env-file if it exists first + if env := os.Getenv("PLUGIN_ENV_FILE"); env != "" { + godotenv.Load(env) + } + app := cli.NewApp() app.Name = "docker plugin" app.Usage = "docker plugin" @@ -129,10 +134,6 @@ func main() { Usage: "docker email", EnvVar: "DOCKER_EMAIL,PLUGIN_EMAIL", }, - cli.StringFlag{ - Name: "env-file", - Usage: "source env file", - }, } if err := app.Run(os.Args); err != nil { @@ -141,10 +142,6 @@ func main() { } func run(c *cli.Context) error { - if c.String("env-file") != "" { - _ = godotenv.Load(c.String("env-file")) - } - plugin := Plugin{ Dryrun: c.Bool("dry-run"), Login: Login{