Skip to content

Commit

Permalink
Initial post-processor
Browse files Browse the repository at this point in the history
  • Loading branch information
jamtur01 committed Jun 25, 2017
1 parent c6577c9 commit da90aa7
Show file tree
Hide file tree
Showing 220 changed files with 85,736 additions and 15 deletions.
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: go

sudo: false

go:
- 1.8
- tip

script:
- 'make build'
131 changes: 131 additions & 0 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Godeps/Readme

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2017 Turnbull Press & James Turnbull [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
default: build

prepare:
go get github.com/tools/godep
godep restore
go get ./...

test: prepare
go test ./...

build: test
go build -v

install: build
mkdir -p ~/.packer.d/plugins
install ./packer-post-processor-slack-notifications ~/.packer.d/plugins/

release: test
go get github.com/mitchellh/gox
gox --output 'dist/{{.OS}}_{{.Arch}}/{{.Dir}}'
zip -j releases/packer-post-processor-slack-notifications_darwin_386.zip dist/darwin_386/packer-post-processor-slack-notifications
zip -j releases/packer-post-processor-slack-notifications_darwin_amd64.zip dist/darwin_amd64/packer-post-processor-slack-notifications
zip -j releases/packer-post-processor-slack-notifications_freebsd_386.zip dist/freebsd_386/packer-post-processor-slack-notifications
zip -j releases/packer-post-processor-slack-notifications_freebsd_amd64.zip dist/freebsd_amd64/packer-post-processor-slack-notifications
zip -j releases/packer-post-processor-slack-notifications_freebsd_arm.zip dist/freebsd_arm/packer-post-processor-slack-notifications
zip -j releases/packer-post-processor-slack-notifications_linux_386.zip dist/linux_386/packer-post-processor-slack-notifications
zip -j releases/packer-post-processor-slack-notifications_linux_amd64.zip dist/linux_amd64/packer-post-processor-slack-notifications
zip -j releases/packer-post-processor-slack-notifications_linux_arm.zip dist/linux_arm/packer-post-processor-slack-notifications
zip -j releases/packer-post-processor-slack-notifications_netbsd_386.zip dist/netbsd_386/packer-post-processor-slack-notifications
zip -j releases/packer-post-processor-slack-notifications_netbsd_amd64.zip dist/netbsd_amd64/packer-post-processor-slack-notifications
zip -j releases/packer-post-processor-slack-notifications_netbsd_arm.zip dist/netbsd_arm/packer-post-processor-slack-notifications
zip -j releases/packer-post-processor-slack-notifications_openbsd_386.zip dist/openbsd_386/packer-post-processor-slack-notifications
zip -j releases/packer-post-processor-slack-notifications_openbsd_amd64.zip dist/openbsd_amd64/packer-post-processor-slack-notifications
zip -j releases/packer-post-processor-slack-notifications_windows_386.zip dist/windows_386/packer-post-processor-slack-notifications.exe
zip -j releases/packer-post-processor-slack-notifications_windows_amd64.zip dist/windows_amd64/packer-post-processor-slack-notifications.exe

clean:
rm -rf dist/
rm -f releases/*.zip

.PHONY: default prepare test build install release clean
103 changes: 103 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# packer-post-processor-slack-notifications

[![Build Status](https://travis-ci.org/turnbullpress/packer-post-processor-slack-notifications.svg?branch=master)](https://travis-ci.org/turnbullpress/packer-post-processor-slack-notifications)
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)

Packer post-processor plugin for Slack notifications

## Description
The Packer Slack Notification post-processor assists you in sending Slack notifications when a build is complete.

## Installation
Packer supports plugins. Please read document the following:
https://www.packer.io/docs/extend/plugins.html

You can download binaries built for your architecture from [latest releases](https://github.com/turnbullpress/packer-post-processor-slack-notifications/releases/latest).

## Usage
The following example `template.json`:

```
{
"builders": [{
"type": "amazon-ebs",
"region": "us-east-1",
"source_ami": "ami-6869aa05",
"instance_type": "t2.micro",
"ssh_username": "ec2-user",
"ssh_pty": "true",
"ami_name": "packer-example {{timestamp}}"
}],
"provisioners":[{
"type": "shell",
"inline": [
"echo 'running...'"
]
}],
"post-processors":[{
"type": "slack-notifications",
"channel": "general",
"url": "https://slackwebhook.url/slackwebhookid"
}]
}
```

### Configuration

Type: `slack-notifications`

Required:
- `channel` (string)
- The channel to which to send the notification.
- `url` (string)
- The Slack Webhook URL

## Developing Plugin

If you wish to build this plugin on your environment, you can use GNU Make build system.
But this Makefile depends on [Go](https://golang.org/). At First, you should install Go.
And we use [godep](https://github.com/tools/godep) for dependency management. Please looks the [reference](https://godoc.org/github.com/tools/godep)

### Run Test
```
make test
go get github.com/tools/godep
godep restore
go get ./...
go test ./...
? github.com/turnbullpress/packer-post-processor-slack-notifications [no test files]
? github.com/turnbullpress/packer-post-processor-slack-notifications/plugin 0.029s
```
Run the unit tests when developing changes to the plugin.

### Installation
```
make install
go get github.com/tools/godep
godep restore
go get ./...
go test ./...
? github.com/turnbullpress/packer-post-processor-slack-notifications [no test files]
? github.com/turnbullpress/packer-post-processor-slack-notifications/plugin 0.023s
go build ./
mkdir -p ~/.packer.d/plugins
install ./packer-post-processor-slack-notifications ~/.packer.d/plugins/
```
Run tests, build and move the compiled plugin to the plugin directory.

### Release
```
make release
go get github.com/tools/godep
godep restore
go get ./...
go test ./...
? github.com/turnbullpress/packer-post-processor-slack-notifications [no test files]
github.com/turnbullpress/packer-post-processor-slack-notifications/plugin 0.020s
...
go get github.com/mitchellh/gox
gox --output 'dist/{{.OS}}_{{.Arch}}/{{.Dir}}'
...
```

Run tests, build for each architecture and archive binaries.
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package main

import (
"github.com/hashicorp/packer/packer/plugin"
"github.com/jamtur01/packer-post-processor-slacknotifications/plugin"
"github.com/turnbullpress/packer-post-processor-slack-notifications/plugin"
)

func main() {
server, err := plugin.Server()
if err != nil {
panic(err)
}

server.RegisterPostProcessor(new(slacknotifications.PostProcessor))
server.Serve()
}
Loading

0 comments on commit da90aa7

Please sign in to comment.