Browse Source

Merge pull request #9 from drone-plugins/feature/additions

Makefile, gitignore and MAINTAINERS improvements
pull/11/head
Thomas Boerger 9 years ago
parent
commit
ca7769b4d5
  1. 27
      .gitignore
  2. 46
      MAINTAINERS
  3. 8
      Makefile
  4. 124
      README.md
  5. 7
      main.go

27
.gitignore

@ -0,0 +1,27 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test
*.prof
coverage.out
drone-terraform

46
MAINTAINERS

@ -0,0 +1,46 @@
[people]
[people.bradrydzewski]
name = "Brad Rydzewski"
email = "brad@drone.io"
login = "bradrydzewski"
[people.Bugagazavr]
name = "Kirill"
email = ""
login = "Bugagazavr"
[people.donny-dont]
name = "Don Olmstead"
email = "donny-dont@gmail.com"
login = "donny-dont"
[people.jackspirou]
name = "Jack Spirou"
email = ""
login = "jackspirou"
[people.msteinert]
name = "Mike Steinert"
email = ""
login = "msteinert"
[people.nlf]
name = "Nathan LaFreniere"
email = ""
login = "nlf"
[people.tboerger]
name = "Thomas Boerger"
email = "thomas@webhippie.de"
login = "tboerger"
[people.athieriot]
name = "Aurélien Thieriot"
email = "a.thieriot@gmail.com"
login = "athieriot"
[org]
[org.core]
people = [
"bradrydzewski",
"Bugagazavr",
"donny-dont",
"jackspirou",
"msteinert",
"nlf",
"tboerger",
"athieriot"
]

8
Makefile

@ -1,12 +1,14 @@
.PHONY: clean deps fmt vet test docker .PHONY: all clean deps fmt vet test docker
EXECUTABLE ?= drone-terraform EXECUTABLE ?= drone-terraform
IMAGE ?= plugins/$(EXECUTABLE) IMAGE ?= plugins/$(EXECUTABLE)
CI_BUILD_NUMBER ?= 0 COMMIT ?= $(shell git rev-parse --short HEAD)
LDFLAGS = -X "main.buildDate=$(shell date -u '+%Y-%m-%d %H:%M:%S %Z')" LDFLAGS = -X "main.buildCommit=$(COMMIT)"
PACKAGES = $(shell go list ./... | grep -v /vendor/) PACKAGES = $(shell go list ./... | grep -v /vendor/)
all: deps build test
clean: clean:
go clean -i ./... go clean -i ./...

124
README.md

@ -1,7 +1,123 @@
# Drone Terraform Deploy Plugin # drone-terraform
This project provides a [Drone](drone.io) plugin docker image that contains the [Terraform](terraform.io) binaries and a small Go app that receives the Drone meta-data and executes Terraform commands. [![Build Status](http://beta.drone.io/api/badges/drone-plugins/drone-terraform/status.svg)](http://beta.drone.io/drone-plugins/drone-terraform)
[![Coverage Status](https://aircover.co/badges/drone-plugins/drone-terraform/coverage.svg)](https://aircover.co/drone-plugins/drone-terraform)
[![](https://badge.imagelayers.io/plugins/drone-terraform:latest.svg)](https://imagelayers.io/?images=plugins/drone-terraform:latest 'Get your own badge on imagelayers.io')
Documentation for Drone Plugin development can be found here: http://readme.drone.io/plugin/ 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](DOCS.md).
See [DOCS](DOCS.md) for details on this plugin's configuration and usage. ## Binary
Build the binary using `make`:
```
make deps build
```
### Example
```sh
./drone-terraform <<EOF
{
"repo": {
"clone_url": "git://github.com/drone/drone",
"owner": "drone",
"name": "drone",
"full_name": "drone/drone"
},
"system": {
"link_url": "https://beta.drone.io"
},
"build": {
"number": 22,
"status": "success",
"started_at": 1421029603,
"finished_at": 1421029813,
"message": "Update the Readme",
"author": "johnsmith",
"author_email": "john.smith@gmail.com",
"event": "push",
"branch": "master",
"commit": "436b7a6e2abaddfd35740527353e78a227ddcb2c",
"ref": "refs/heads/master"
},
"workspace": {
"root": "/drone/src",
"path": "/drone/src/github.com/drone/drone"
},
"vargs": {
"plan": false,
"remote": {
"backend": "S3",
"config": {
"bucket": "my-terraform-config-bucket",
"key": "tf-states/my-project",
"region": "us-east-1"
}
},
"vars": {
"app_name": "my-project",
"app_version": "1.0.0"
}
}
}
EOF
```
## Docker
Build the container using `make`:
```
make deps docker
```
### Example
```sh
docker run -i plugins/drone-terraform <<EOF
{
"repo": {
"clone_url": "git://github.com/drone/drone",
"owner": "drone",
"name": "drone",
"full_name": "drone/drone"
},
"system": {
"link_url": "https://beta.drone.io"
},
"build": {
"number": 22,
"status": "success",
"started_at": 1421029603,
"finished_at": 1421029813,
"message": "Update the Readme",
"author": "johnsmith",
"author_email": "john.smith@gmail.com",
"event": "push",
"branch": "master",
"commit": "436b7a6e2abaddfd35740527353e78a227ddcb2c",
"ref": "refs/heads/master"
},
"workspace": {
"root": "/drone/src",
"path": "/drone/src/github.com/drone/drone"
},
"vargs": {
"plan": false,
"remote": {
"backend": "S3",
"config": {
"bucket": "my-terraform-config-bucket",
"key": "tf-states/my-project",
"region": "us-east-1"
}
},
"vars": {
"app_name": "my-project",
"app_version": "1.0.0"
}
}
}
EOF
```

7
main.go

@ -2,14 +2,18 @@ package main
import ( import (
"fmt" "fmt"
"io/ioutil"
"os" "os"
"os/exec" "os/exec"
"strings" "strings"
"io/ioutil"
"github.com/drone/drone-plugin-go/plugin" "github.com/drone/drone-plugin-go/plugin"
) )
var (
buildCommit string
)
type terraform struct { type terraform struct {
Remote remote `json:"remote"` Remote remote `json:"remote"`
Plan bool `json:"plan"` Plan bool `json:"plan"`
@ -24,6 +28,7 @@ type remote struct {
} }
func main() { func main() {
fmt.Printf("Drone Terraform Plugin built from %s\n", buildCommit)
workspace := plugin.Workspace{} workspace := plugin.Workspace{}
vargs := terraform{} vargs := terraform{}

Loading…
Cancel
Save