Browse Source

Merge b03bd99110 into 43f03d0d0c

pull/78/merge
Chris Mague 7 years ago
committed by GitHub
parent
commit
da577892b9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CHANGELOG.md
  2. 75
      DOCS.md
  3. 49
      Dockerfile
  4. 10
      README.md
  5. 14
      main.go
  6. 171
      plugin.go
  7. 45
      plugin_test.go
  8. 32
      terraform.go
  9. 2
      vendor/vendor.json

2
CHANGELOG.md

@ -20,7 +20,7 @@ See [DOCS.md](DOCS.md) for more info and examples.
* Update embedded TF to `0.10.8`
## 4.0-0.10.7 (2017-10-20)
* Persist state locking config (https://github.com/jmccann/drone-terraform/pull/55)
* Persist state locking config (https://github.com/quay.io/agari/agari-drone-terraform/pull/55)
* Update embedded TF to `0.10.7`
## 4.0-0.10.3 (2017-09-06)

75
DOCS.md

@ -3,17 +3,17 @@ date: 2016-01-01T00:00:00+00:00
title: Terraform
author: jmccann
tags: [ infrastructure, build tool ]
repo: jmccann/drone-terraform
repo: quay.io/agari/agari-drone-terraform
logo: terraform.svg
image: jmccann/drone-terraform
image: quay.io/agari/agari-drone-terraform
---
The Terraform plugin applies the infrastructure configuration contained within the repository. The below pipeline configuration demonstrates simple usage which will run a `validate`, `plan` and `apply`:
The Terraform plugin applies the infrastructure configuration contained within the repository. The below pipeline configuration demonstrates simple usage which will run a `validate`, `show`, `plan` and `apply`:
```yaml
pipeline:
terraform:
image: jmccann/drone-terraform:5
image: quay.io/agari/agari-drone-terraform:5
```
Example configuration passing `vars` to terraform commands:
@ -21,7 +21,7 @@ Example configuration passing `vars` to terraform commands:
```diff
pipeline:
terraform:
image: jmccann/drone-terraform:5
image: quay.io/agari/agari-drone-terraform:5
+ vars:
+ app_name: my-project
+ app_version: 1.0.0
@ -32,10 +32,13 @@ Example of explicitly specifying `actions` to perform a dry run.
```diff
pipeline:
terraform:
image: jmccann/drone-terraform:5
image: quay.io/agari/agari-drone-terraform:5
planfile: "../planshare.out"
difffile: "../diff.out"
+ actions:
+ - validate
+ - plan
+ - show
```
Example configuration passing secrets to terraform. Please read
@ -47,7 +50,7 @@ for more details.
```diff
pipeline:
terraform:
image: jmccann/drone-terraform:5
image: quay.io/agari/agari-drone-terraform:5
+ secrets:
+ - source: terraform_secret
+ target: tf_var_my_secret
@ -58,12 +61,12 @@ pipeline:
```diff
pipeline:
terraform_1:
image: jmccann/drone-terraform:5
image: quay.io/agari/agari-drone-terraform:5
+ environment:
+ TF_VAR_MY_SECRET: ${TERRAFORM_SECRET}
terraform_2:
image: jmccann/drone-terraform:5
image: quay.io/agari/agari-drone-terraform:5
plan: false
+ sensitive: true
+ vars:
@ -78,7 +81,7 @@ what command is actually being ran.
```diff
pipeline:
terraform:
image: jmccann/drone-terraform:5
image: quay.io/agari/agari-drone-terraform:5
+ sensitive: true
```
@ -89,7 +92,7 @@ specified instead of using the embedded version that is included.
```diff
pipeline:
terraform:
image: jmccann/drone-terraform:5
image: quay.io/agari/agari-drone-terraform:5
+ tf_version: 0.10.3
```
@ -100,7 +103,7 @@ specified in a `.tf` file. You can then pass additional options via the `.drone
```diff
pipeline:
terraform:
image: jmccann/drone-terraform:5
image: quay.io/agari/agari-drone-terraform:5
+ init_options:
+ backend-config:
+ - "bucket=my-terraform-config-bucket"
@ -116,7 +119,7 @@ CA Certificate. You can inject your CA Certificate into the plugin by using
```diff
pipeline:
terraform:
image: jmccann/drone-terraform:5
image: quay.io/agari/agari-drone-terraform:5
+ ca_cert: |
+ -----BEGIN CERTIFICATE-----
+ asdfsadf
@ -133,7 +136,7 @@ See [the discussion](https://github.com/hashicorp/terraform/issues/1275) in the
```diff
pipeline:
terraform:
image: jmccann/drone-terraform:5
image: quay.io/agari/agari-drone-terraform:5
+ role_arn_to_assume: arn:aws:iam::account-of-role-to-assume:role/name-of-role
```
@ -144,7 +147,7 @@ and you want to use different drone configurations to apply different environmen
```diff
pipeline:
terraform:
image: jmccann/drone-terraform:5
image: quay.io/agari/agari-drone-terraform:5
+ root_dir: some/path/here
```
@ -155,7 +158,7 @@ all resources will be planned/applied against as the default behavior.
```diff
pipeline:
terraform:
image: jmccann/drone-terraform:5
image: quay.io/agari/agari-drone-terraform:5
+ targets:
+ - aws_security_group.generic_sg
+ - aws_security_group.app_sg
@ -167,20 +170,50 @@ If you want to change Terraform's default parallelism (currently equal to 10) th
```diff
pipeline:
terraform:
image: jmccann/drone-terraform:5
image: quay.io/agari/agari-drone-terraform:5
+ parallelism: 2
```
You may want to specify the out directory of the plan file so you can pass it to builds further down the pipeline
If you want to change Terraform's default outfile (currently plan.tfout in the cwd) then set the `plan_path` parameter.
```diff
pipeline:
terraform:
image: quay.io/agari/agari-drone-terraform:5
+ plan_path: /tmp/a.out
```
Destroying the service can be done by specifying `plan-destroy` and `destroy` actions. Keep in mind that Fastly won't allow a service with active version be destroyed. Use `force_destroy` option in the service definition for terraform to handle it.
Destroying the service can be done by specifying `plan-destroy` and `destroy` actions. Keep in mind that Fastly won't allow a service with active version be destroyed. Use `force_destroy` option in the service definition for terraform to handle it.
```yaml
pipeline:
destroy:
image: jmccann/drone-terraform:5
image: quay.io/agari/agari-drone-terraform:5
+ actions:
+ - plan-destroy
+ - destroy
```
# Environment variables
- PEM_NAME
If this environment variable is set, a file called ~/.ssh/<PEM_NAME> will be created
- PEM_CONTENTS
If this environment variable is set, the contents will be put in ~/.ssh/<PEM_NAME>
Please be sure to include the "-----BEGIN RSA PRIVATE KEY-----" and end lines for a valid key
- GITHUB_PRIVATE_SSH_KEY
If this environment variable is set, ~/.ssh/id_rsa will be set.
Please be sure to include the "-----BEGIN RSA PRIVATE KEY-----" and end lines for a valid key
- AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
If this environment variable is set a ~/.aws/credentials file will be added with the name of the AWS_PROFILE
- AWS_PROFILE (default: `drone-testing`)
If a profile is created, it will be set to this name
# Parameter Reference
@ -224,3 +257,9 @@ root_dir
parallelism
: The number of concurrent operations as Terraform walks its graph.
# Testing Locally
```
docker run -e PEM_NAME=my.pem -w /root/test -v `pwd`:/root quay.io/agari/agari-drone-terraform
```

49
Dockerfile

@ -1,6 +1,10 @@
#################################################################################################
# Docker image for the Drone Terraform plugin
#
# docker build -t jmccann/drone-terraform:latest .
#################################################################################################
# Build the Go binary
FROM golang:1.10-alpine AS builder
COPY ./*.go ./src/
COPY ./vendor/ ./src/
@ -8,19 +12,60 @@ RUN set -ex \
&& cd ./src \
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo -o /go/bin/drone-terraform
#################################################################################################
# Build the Terraform plugin
FROM golang:1.10-alpine AS tfbuilder
RUN apk -U add \
ca-certificates \
git \
bash \
wget \
rm -rf /var/cache/apk/*
RUN mkdir -p /go/src/github.com/sl1pm4t \
&& cd /go/src/github.com/sl1pm4t \
&& git clone https://github.com/sl1pm4t/terraform-provider-kubernetes.git \
&& cd ./terraform-provider-kubernetes \
&& go get -v \
&& GOOS=linux GOARCH=amd64 go build -v -o /go/bin/terraform-provider-kubernetes \
&& ls -al /go/bin/terraform-provider-kubernetes
#################################################################################################
# Build the actual container
FROM alpine:3.7
RUN apk -U add \
ca-certificates \
git \
ansible \
jq \
bash \
wget \
openssh-client && \
rm -rf /var/cache/apk/*
ENV TERRAFORM_VERSION 0.11.7
ENV TERRAFORM_VERSION 0.11.8
ENV AWS_PROFILE drone-testing
RUN wget -q https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -O terraform.zip && \
unzip terraform.zip -d /bin && \
rm -f terraform.zip
RUN wget -P /usr/local/bin/ https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-07-26/bin/linux/amd64/aws-iam-authenticator && \
chmod +x /usr/local/bin/aws-iam-authenticator
RUN wget -P /usr/local/bin/ https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-07-26/bin/linux/amd64/kubectl && \
chmod +x /usr/local/bin/kubectl
RUN mkdir -p /root/.terraform.d/plugins/
# Ensure we have github key in known hosts
RUN mkdir /root/.ssh && chmod 700 /root/.ssh
RUN ssh-keyscan github.com >> /root/.ssh/known_hosts
COPY --from=tfbuilder /go/bin/terraform-provider-kubernetes /root/.terraform.d/plugins/
COPY --from=builder /go/bin/drone-terraform /bin/
ENTRYPOINT ["/bin/drone-terraform"]

10
README.md

@ -1,9 +1,9 @@
# drone-terraform
[![Build Status](http://beta.drone.io/api/badges/jmccann/drone-terraform/status.svg)](http://beta.drone.io/jmccann/drone-terraform)
[![Build Status](http://beta.drone.io/api/badges/quay.io/agari/agari-drone-terraform/status.svg)](http://beta.drone.io/quay.io/agari/agari-drone-terraform)
Drone plugin to execute Terraform plan and apply. For the usage information and
a listing of the available options please take a look at [the docs](https://github.com/jmccann/drone-terraform/blob/master/DOCS.md).
a listing of the available options please take a look at [the docs](https://github.com/quay.io/agari/agari-drone-terraform/blob/master/DOCS.md).
## Build
@ -20,7 +20,7 @@ Build the docker image with the following commands:
```
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo
docker build --rm=true -t jmccann/drone-terraform .
docker build --rm=true -t quay.io/agari/agari-drone-terraform .
```
Please note incorrectly building the image for the correct x64 linux and with
@ -39,9 +39,9 @@ Execute from the working directory:
docker run --rm \
-v $(pwd):$(pwd) \
-w $(pwd) \
jmccann/drone-terraform:latest --plan
quay.io/agari/agari-drone-terraform:latest --plan
```
## Drone 0.4
Legacy `drone-terraform` plugin exists @ `jmccann/drone-terraform:0.4`
Legacy `drone-terraform` plugin exists @ `quay.io/agari/agari-drone-terraform:0.4`

14
main.go

@ -27,7 +27,7 @@ func main() {
Name: "actions",
Usage: "a list of actions to have terraform perform",
EnvVar: "PLUGIN_ACTIONS",
Value: &cli.StringSlice{"validate", "plan", "apply"},
Value: &cli.StringSlice{"validate", "plan", "show", "apply"},
},
cli.StringFlag{
Name: "ca_cert",
@ -38,6 +38,16 @@ func main() {
Name: "env-file",
Usage: "source env file",
},
cli.StringFlag{
Name: "planfile",
Usage: "The absolute path to save the outfile eg: /tmp/myplan.tfout",
EnvVar: "PLUGIN_PLANFILE",
},
cli.StringFlag{
Name: "difffile",
Usage: "The absolute path to save the diff file to eg: /tmp/myplan.diff",
EnvVar: "PLUGIN_DIFFFILE",
},
cli.StringFlag{
Name: "init_options",
Usage: "options for the init command. See https://www.terraform.io/docs/commands/init.html",
@ -146,6 +156,8 @@ func run(c *cli.Context) error {
RoleARN: c.String("role_arn_to_assume"),
RootDir: c.String("root_dir"),
Parallelism: c.Int("parallelism"),
Planfile: c.String("planfile"),
Difffile: c.String("difffile"),
Targets: c.StringSlice("targets"),
VarFiles: c.StringSlice("var_files"),
},

171
plugin.go

@ -28,6 +28,8 @@ type (
Cacert string
Sensitive bool
RoleARN string
Planfile string
Difffile string
RootDir string
Parallelism int
Targets []string
@ -54,12 +56,49 @@ type (
Netrc Netrc
Terraform Terraform
}
TfCommand struct {
Tfcmd *exec.Cmd
Ofile string
}
)
// Exec executes the plugin
func (p Plugin) Exec() error {
// Install a extra PEM key if required
if len(os.Getenv("PEM_NAME")) > 0 {
value, exists := os.LookupEnv("PEM_CONTENTS")
if !exists {
value = "-----BEGIN RSA PRIVATE KEY-----\n\n-----END RSA PRIVATE KEY-----\n"
}
err := installExtraPem(os.Getenv("PEM_NAME"), value)
if err != nil {
return err
}
}
// Install a Github SSH key
if len(os.Getenv("GITHUB_PRIVATE_SSH_KEY")) > 0 {
sshconfErr := installGithubSsh(os.Getenv("GITHUB_PRIVATE_SSH_KEY"))
if sshconfErr != nil {
return sshconfErr
}
}
// Install an AWS profile if env var is set
if len(os.Getenv("AWS_ACCESS_KEY_ID")) > 0 {
profileErr := installProfile(os.Getenv("AWS_PROFILE"), os.Getenv("AWS_ACCESS_KEY_ID"), os.Getenv("AWS_SECRET_ACCESS_KEY"))
if profileErr != nil {
return profileErr
}
}
// Install specified version of terraform
if p.Terraform.Version != "" {
err := installTerraform(p.Terraform.Version)
if err != nil {
@ -77,17 +116,17 @@ func (p Plugin) Exec() error {
return err
}
var commands []*exec.Cmd
var commands []TfCommand
commands = append(commands, exec.Command("terraform", "version"))
commands = append(commands, TfCommand{Tfcmd: exec.Command("terraform", "version")})
CopyTfEnv()
if p.Config.Cacert != "" {
commands = append(commands, installCaCert(p.Config.Cacert))
commands = append(commands, TfCommand{Tfcmd: installCaCert(p.Config.Cacert)})
}
commands = append(commands, deleteCache())
commands = append(commands, TfCommand{Tfcmd: deleteCache()})
commands = append(commands, initCommand(p.Config.InitOptions))
commands = append(commands, getModules())
@ -102,38 +141,70 @@ func (p Plugin) Exec() error {
commands = append(commands, tfPlan(p.Config, true))
case "apply":
commands = append(commands, tfApply(p.Config))
case "show":
commands = append(commands, tfShow(p.Config))
case "destroy":
commands = append(commands, tfDestroy(p.Config))
default:
return fmt.Errorf("valid actions are: validate, plan, apply, plan-destroy, destroy. You provided %s", action)
return fmt.Errorf("valid actions are: validate, plan, show, apply, plan-destroy, destroy. You provided %s", action)
}
}
commands = append(commands, deleteCache())
commands = append(commands, TfCommand{Tfcmd: deleteCache()})
for _, c := range commands {
if c.Dir == "" {
if c.Tfcmd.Dir == "" {
wd, err := os.Getwd()
if err == nil {
c.Dir = wd
c.Tfcmd.Dir = wd
}
}
if p.Config.RootDir != "" {
c.Dir = c.Dir + "/" + p.Config.RootDir
}
c.Stdout = os.Stdout
c.Stderr = os.Stderr
if !p.Config.Sensitive {
trace(c)
c.Tfcmd.Dir = c.Tfcmd.Dir + "/" + p.Config.RootDir
}
err := c.Run()
if err != nil {
if c.Ofile == "" {
c.Tfcmd.Stdout = os.Stdout
c.Tfcmd.Stderr = os.Stderr
if !p.Config.Sensitive {
trace(c.Tfcmd)
}
err := c.Tfcmd.Run()
if err != nil {
logrus.WithFields(logrus.Fields{
"error": err,
}).Fatal("Failed to execute a command")
}
} else {
logrus.WithFields(logrus.Fields{
"error": err,
}).Fatal("Failed to execute a command")
"file": c.Ofile,
"command": strings.Join(c.Tfcmd.Args, " "),
}).Info("Command")
out, err := c.Tfcmd.CombinedOutput()
if err != nil {
logrus.WithFields(logrus.Fields{
"command": strings.Join(c.Tfcmd.Args, " "),
"error": err,
}).Fatal("Failed to execute a command")
}
f, outferr := os.Create(c.Ofile)
if outferr != nil {
logrus.WithFields(logrus.Fields{
"command": strings.Join(c.Tfcmd.Args, " "),
"error": outferr,
}).Fatal("Failed to write file")
}
f.Write(out)
f.Sync()
logrus.WithFields(logrus.Fields{
"file": c.Ofile,
"contenets": string(out),
}).Info("Logging output")
f.Close()
}
logrus.Debug("Command completed successfully")
}
return nil
@ -180,14 +251,15 @@ func deleteCache() *exec.Cmd {
)
}
func getModules() *exec.Cmd {
return exec.Command(
func getModules() TfCommand {
cmd := exec.Command(
"terraform",
"get",
)
return (TfCommand{Tfcmd: cmd})
}
func initCommand(config InitOptions) *exec.Cmd {
func initCommand(config InitOptions) TfCommand {
args := []string{
"init",
}
@ -209,10 +281,11 @@ func initCommand(config InitOptions) *exec.Cmd {
// Fail Terraform execution on prompt
args = append(args, "-input=false")
return exec.Command(
cmd := exec.Command(
"terraform",
args...,
)
return (TfCommand{Tfcmd: cmd})
}
func installCaCert(cacert string) *exec.Cmd {
@ -226,7 +299,26 @@ func trace(cmd *exec.Cmd) {
fmt.Println("$", strings.Join(cmd.Args, " "))
}
func tfApply(config Config) *exec.Cmd {
func tfShow(config Config) TfCommand {
args := []string{
"show",
"-no-color",
}
ofile := config.Difffile
if config.Difffile != "" {
args = append(args, config.Planfile)
}
cmd := exec.Command(
"terraform",
args...,
)
return (TfCommand{Tfcmd: cmd, Ofile: ofile})
}
func tfApply(config Config) TfCommand {
args := []string{
"apply",
}
@ -242,14 +334,19 @@ func tfApply(config Config) *exec.Cmd {
if config.InitOptions.LockTimeout != "" {
args = append(args, fmt.Sprintf("-lock-timeout=%s", config.InitOptions.LockTimeout))
}
args = append(args, "plan.tfout")
return exec.Command(
if config.Planfile != "" {
args = append(args, config.Planfile)
} else {
args = append(args, "plan.tfout")
}
cmd := exec.Command(
"terraform",
args...,
)
return (TfCommand{Tfcmd: cmd})
}
func tfDestroy(config Config) *exec.Cmd {
func tfDestroy(config Config) TfCommand {
args := []string{
"destroy",
}
@ -268,19 +365,27 @@ func tfDestroy(config Config) *exec.Cmd {
args = append(args, fmt.Sprintf("-lock-timeout=%s", config.InitOptions.LockTimeout))
}
args = append(args, "-force")
return exec.Command(
cmd := exec.Command(
"terraform",
args...,
)
return (TfCommand{Tfcmd: cmd})
}
func tfPlan(config Config, destroy bool) *exec.Cmd {
func tfPlan(config Config, destroy bool) TfCommand {
args := []string{
"plan",
}
logrus.WithFields(logrus.Fields{
"Config.Parallelism": config.Parallelism,
"Config.Planfile": config.Planfile,
}).Info("Configuration")
if destroy {
args = append(args, "-destroy")
} else if config.Planfile != "" {
args = append(args, fmt.Sprintf("-out=%s", config.Planfile))
} else {
args = append(args, "-out=plan.tfout")
}
@ -299,13 +404,14 @@ func tfPlan(config Config, destroy bool) *exec.Cmd {
if config.InitOptions.LockTimeout != "" {
args = append(args, fmt.Sprintf("-lock-timeout=%s", config.InitOptions.LockTimeout))
}
return exec.Command(
cmd := exec.Command(
"terraform",
args...,
)
return (TfCommand{Tfcmd: cmd})
}
func tfValidate(config Config) *exec.Cmd {
func tfValidate(config Config) TfCommand {
args := []string{
"validate",
}
@ -315,10 +421,11 @@ func tfValidate(config Config) *exec.Cmd {
for k, v := range config.Vars {
args = append(args, "-var", fmt.Sprintf("%s=%s", k, v))
}
return exec.Command(
cmd := exec.Command(
"terraform",
args...,
)
return (TfCommand{Tfcmd: cmd})
}
func vars(vs map[string]string) []string {

45
plugin_test.go

@ -27,6 +27,34 @@ func TestPlugin(t *testing.T) {
})
})
g.Describe("tfShow", func() {
g.It("Should return correct apply commands given the arguments", func() {
type args struct {
config Config
}
tests := []struct {
name string
args args
want *exec.Cmd
}{
{
"default",
args{config: Config{}},
exec.Command("terraform", "show", "-no-color"),
},
{
"with planfile",
args{config: Config{Planfile: "/tmp/plan.tfout", Difffile: "/tmp/plan.diff"}},
exec.Command("terraform", "show", "-no-color", "/tmp/plan.tfout"),
},
}
for _, tt := range tests {
g.Assert(tfShow(tt.args.config).Tfcmd).Equal(tt.want)
}
})
})
g.Describe("tfApply", func() {
g.It("Should return correct apply commands given the arguments", func() {
type args struct {
@ -43,6 +71,11 @@ func TestPlugin(t *testing.T) {
args{config: Config{}},
exec.Command("terraform", "apply", "plan.tfout"),
},
{
"with path",
args{config: Config{Planfile: "/tmp/a.tfout"}},
exec.Command("terraform", "apply", "/tmp/a.tfout"),
},
{
"with parallelism",
args{config: Config{Parallelism: 5}},
@ -56,7 +89,7 @@ func TestPlugin(t *testing.T) {
}
for _, tt := range tests {
g.Assert(tfApply(tt.args.config)).Equal(tt.want)
g.Assert(tfApply(tt.args.config).Tfcmd).Equal(tt.want)
}
})
})
@ -100,7 +133,7 @@ func TestPlugin(t *testing.T) {
}
for _, tt := range tests {
g.Assert(tfDestroy(tt.args.config)).Equal(tt.want)
g.Assert(tfDestroy(tt.args.config).Tfcmd).Equal(tt.want)
}
})
})
@ -123,6 +156,12 @@ func TestPlugin(t *testing.T) {
false,
exec.Command("terraform", "plan", "-out=plan.tfout"),
},
{
"with path",
args{config: Config{Planfile: "/tmp/a.tfout"}},
false,
exec.Command("terraform", "plan", "-out=/tmp/a.tfout"),
},
{
"destroy",
args{config: Config{}},
@ -144,7 +183,7 @@ func TestPlugin(t *testing.T) {
}
for _, tt := range tests {
g.Assert(tfPlan(tt.args.config, tt.destroy)).Equal(tt.want)
g.Assert(tfPlan(tt.args.config, tt.destroy).Tfcmd).Equal(tt.want)
}
})
})

32
terraform.go

@ -4,6 +4,7 @@ import (
"archive/zip"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"path/filepath"
@ -16,6 +17,37 @@ type (
}
)
func installExtraPem(pemName string, pemContents string) error {
os.Mkdir(os.Getenv("HOME")+"/.ssh", 0700)
err := ioutil.WriteFile(os.Getenv("HOME")+"/.ssh/"+pemName, []byte(pemContents), 0600)
if err != nil {
return err
}
return nil
}
func installGithubSsh(githubSshPrivate string) error {
os.Mkdir(os.Getenv("HOME")+"/.aws", 0700)
myconf := []byte("Host github.com\n StrictHostKeyChecking no\n UserKnownHostsFile=/dev/null\n")
err := ioutil.WriteFile(os.Getenv("HOME")+"/.ssh/conf", myconf, 0644)
if err != nil {
return err
}
mykey := []byte(githubSshPrivate)
err2 := ioutil.WriteFile(os.Getenv("HOME")+"/.ssh/id_rsa", mykey, 0600)
if err2 != nil {
return err2
}
return nil
}
func installProfile(profileName string, profileKey string, profileSecret string) error {
os.Mkdir(os.Getenv("HOME")+"/.aws", 0700)
myconf := []byte("[" + profileName + "]\naws_access_key_id = " + profileKey + "\naws_secret_access_key = " + profileSecret + "\n")
err := ioutil.WriteFile(os.Getenv("HOME")+"/.aws/credentials", myconf, 0644)
return err
}
func installTerraform(version string) error {
err := downloadTerraform(version)
if err != nil {

2
vendor/vendor.json

@ -181,5 +181,5 @@
"revisionTime": "2016-10-06T02:47:49Z"
}
],
"rootPath": "github.com/jmccann/drone-terraform"
"rootPath": "github.com/quay.io/agari/agari-drone-terraform"
}

Loading…
Cancel
Save