Eric Ho
6 years ago
No known key found for this signature in database
GPG Key ID: 4397AE5628A156C
3 changed files with
52 additions and
30 deletions
-
build-docker.sh
-
main.go
-
plugin.go
|
|
@ -13,15 +13,15 @@ minor=$(echo $tag | awk -F. '{print $2}') |
|
|
|
|
|
|
|
tf_ver=$(grep TERRAFORM_VERSION Dockerfile | head -n 1 | awk '{print $3}') |
|
|
|
|
|
|
|
docker build -t jmccann/drone-terraform:latest . |
|
|
|
docker build -t moneysmartco/drone-terraform:latest . |
|
|
|
|
|
|
|
set -x |
|
|
|
docker tag jmccann/drone-terraform:latest jmccann/drone-terraform:${major} |
|
|
|
docker tag jmccann/drone-terraform:latest jmccann/drone-terraform:${major}.${minor} |
|
|
|
docker tag jmccann/drone-terraform:latest jmccann/drone-terraform:${major}.${minor}-${tf_ver} |
|
|
|
docker tag moneysmartco/drone-terraform:latest moneysmartco/drone-terraform:${major} |
|
|
|
docker tag moneysmartco/drone-terraform:latest moneysmartco/drone-terraform:${major}.${minor} |
|
|
|
docker tag moneysmartco/drone-terraform:latest moneysmartco/drone-terraform:${major}.${minor}-${tf_ver} |
|
|
|
|
|
|
|
docker push jmccann/drone-terraform:latest |
|
|
|
docker push jmccann/drone-terraform:${major} |
|
|
|
docker push jmccann/drone-terraform:${major}.${minor} |
|
|
|
docker push jmccann/drone-terraform:${major}.${minor}-${tf_ver} |
|
|
|
docker push moneysmartco/drone-terraform:latest |
|
|
|
docker push moneysmartco/drone-terraform:${major} |
|
|
|
docker push moneysmartco/drone-terraform:${major}.${minor} |
|
|
|
docker push moneysmartco/drone-terraform:${major}.${minor}-${tf_ver} |
|
|
|
set +x |
|
|
@ -103,6 +103,12 @@ func main() { |
|
|
|
Usage: "a list of var files to use. Each value is passed as -var-file=<value>", |
|
|
|
EnvVar: "PLUGIN_VAR_FILES", |
|
|
|
}, |
|
|
|
cli.StringFlag{ |
|
|
|
Name: "deploy-env-path", |
|
|
|
Usage: "Path to save the dotenv file", |
|
|
|
EnvVar: "PLUGIN_DEPLOY_ENV_PATH", |
|
|
|
Value: ".deploy.env", |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
if err := app.Run(os.Args); err != nil { |
|
|
@ -148,6 +154,7 @@ func run(c *cli.Context) error { |
|
|
|
Parallelism: c.Int("parallelism"), |
|
|
|
Targets: c.StringSlice("targets"), |
|
|
|
VarFiles: c.StringSlice("var_files"), |
|
|
|
DeployEnvPath: c.String("deploy-env-path"), |
|
|
|
}, |
|
|
|
Netrc: Netrc{ |
|
|
|
Login: c.String("netrc.username"), |
|
|
|
|
|
@ -16,6 +16,7 @@ import ( |
|
|
|
"github.com/aws/aws-sdk-go/aws/credentials/stscreds" |
|
|
|
"github.com/aws/aws-sdk-go/aws/session" |
|
|
|
"github.com/aws/aws-sdk-go/service/sts" |
|
|
|
"github.com/joho/godotenv" |
|
|
|
) |
|
|
|
|
|
|
|
type ( |
|
|
@ -32,6 +33,7 @@ type ( |
|
|
|
Parallelism int |
|
|
|
Targets []string |
|
|
|
VarFiles []string |
|
|
|
DeployEnvPath string |
|
|
|
} |
|
|
|
|
|
|
|
// Netrc is credentials for cloning
|
|
|
@ -81,6 +83,7 @@ func (p Plugin) Exec() error { |
|
|
|
|
|
|
|
commands = append(commands, exec.Command("terraform", "version")) |
|
|
|
|
|
|
|
p.CopyDeployEnv() |
|
|
|
CopyTfEnv() |
|
|
|
|
|
|
|
if p.Config.Cacert != "" { |
|
|
@ -139,6 +142,18 @@ func (p Plugin) Exec() error { |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
// CopyDeployEnv export env var from DeployEnvPath file
|
|
|
|
func (p Plugin) CopyDeployEnv() { |
|
|
|
envMap, err := godotenv.Read(p.Config.DeployEnvPath) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
for k, v := range envMap { |
|
|
|
os.Setenv(k, v) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// CopyTfEnv creates copies of TF_VAR_ to lowercase
|
|
|
|
func CopyTfEnv() { |
|
|
|
tfVar := regexp.MustCompile(`^TF_VAR_.*$`) |
|
|
|