From a5076e74dc4c6c04ca6669dc309577fbdc2d0abf Mon Sep 17 00:00:00 2001 From: Robert Stettner Date: Wed, 5 Aug 2020 16:28:21 +0100 Subject: [PATCH] Added env-file with godotenv to all non-base implementations of plugin --- cmd/drone-acr/main.go | 7 +++++++ cmd/drone-ecr/main.go | 7 +++++++ cmd/drone-gcr/main.go | 7 +++++++ cmd/drone-heroku/main.go | 7 +++++++ 4 files changed, 28 insertions(+) diff --git a/cmd/drone-acr/main.go b/cmd/drone-acr/main.go index 6ef7696..62e65c5 100644 --- a/cmd/drone-acr/main.go +++ b/cmd/drone-acr/main.go @@ -5,9 +5,16 @@ import ( "os" "os/exec" "strings" + + "github.com/joho/godotenv" ) func main() { + // Load env-file if it exists first + if env := os.Getenv("PLUGIN_ENV_FILE"); env != "" { + godotenv.Load(env) + } + var ( repo = getenv("PLUGIN_REPO") registry = getenv("PLUGIN_REGISTRY") diff --git a/cmd/drone-ecr/main.go b/cmd/drone-ecr/main.go index 1390d8e..5f1e83e 100644 --- a/cmd/drone-ecr/main.go +++ b/cmd/drone-ecr/main.go @@ -10,6 +10,8 @@ import ( "strconv" "strings" + "github.com/joho/godotenv" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/credentials/stscreds" @@ -20,6 +22,11 @@ import ( const defaultRegion = "us-east-1" func main() { + // Load env-file if it exists first + if env := os.Getenv("PLUGIN_ENV_FILE"); env != "" { + godotenv.Load(env) + } + var ( repo = getenv("PLUGIN_REPO") registry = getenv("PLUGIN_REGISTRY") diff --git a/cmd/drone-gcr/main.go b/cmd/drone-gcr/main.go index cad17c8..addddcb 100644 --- a/cmd/drone-gcr/main.go +++ b/cmd/drone-gcr/main.go @@ -6,12 +6,19 @@ import ( "os/exec" "path" "strings" + + "github.com/joho/godotenv" ) // gcr default username const username = "_json_key" func main() { + // Load env-file if it exists first + if env := os.Getenv("PLUGIN_ENV_FILE"); env != "" { + godotenv.Load(env) + } + var ( repo = getenv("PLUGIN_REPO") registry = getenv("PLUGIN_REGISTRY") diff --git a/cmd/drone-heroku/main.go b/cmd/drone-heroku/main.go index 57a2ae8..7a5ca49 100644 --- a/cmd/drone-heroku/main.go +++ b/cmd/drone-heroku/main.go @@ -4,9 +4,16 @@ import ( "os" "os/exec" "path" + + "github.com/joho/godotenv" ) func main() { + // Load env-file if it exists first + if env := os.Getenv("PLUGIN_ENV_FILE"); env != "" { + godotenv.Load(env) + } + var ( registry = "registry.heroku.com" process = getenv("PLUGIN_PROCESS_TYPE")