refactor the code according hashicorp rename the repository

This commit is contained in:
zhuzhih2017 2017-04-17 21:04:52 +08:00
commit d646e1d035
880 changed files with 10211 additions and 9371 deletions

View File

@ -1,6 +1,7 @@
**DELETE THIS TEMPLATE BEFORE SUBMITTING** **DELETE THIS TEMPLATE BEFORE SUBMITTING**
_Only use Github issues to report bugs or feature requests, see https://www.packer.io/community/_ _Only use Github issues to report bugs or feature requests, see
https://www.packer.io/community.html_
If you are planning to open a pull-request just open the pull-request instead of making an issue first. If you are planning to open a pull-request just open the pull-request instead of making an issue first.

View File

@ -4,8 +4,8 @@ Describe the change you are making here!
Please include tests. Check out these examples: Please include tests. Check out these examples:
- https://github.com/mitchellh/packer/blob/master/builder/virtualbox/common/ssh_config_test.go#L19-L37 - https://github.com/hashicorp/packer/blob/master/builder/virtualbox/common/ssh_config_test.go#L19-L37
- https://github.com/mitchellh/packer/blob/master/post-processor/compress/post-processor_test.go#L153-L182 - https://github.com/hashicorp/packer/blob/master/post-processor/compress/post-processor_test.go#L153-L182
If your PR resolves any open issue(s), please indicate them like this so they will be closed when your PR is merged: If your PR resolves any open issue(s), please indicate them like this so they will be closed when your PR is merged:

View File

@ -1,7 +1,52 @@
## (Unreleased) ## (Unreleased)
### IMPROVEMENTS:
* builder/amazon: validate ami name. [GH-4762]
* builder/digitalocean: Added support for monitoring. [GH-4782]
* builder/openstack: Add ssh agent support. [GH-4655]
* builder/parallels-iso: Configuration of disk type, plain or expanding.
[GH-4621]
## 1.0.0 (April 4, 2017)
### BUG FIXES:
* core: fix version number
* communicator/ssh: don't return error if we can't close connection. #4741
* builder/googlecompute: Use "default" service account. [GH-4749]
* core: Invoking packer `--help` or `--version` now exits with status 0.
[GH-4723]
* core: show correct step name when debugging. [GH-4672]
* builder/virtualbox: fix `none` communicator by allowing skipping upload of
version file. [GH-4678]
* communicator/ssh: fix nil pointer error. [GH-4690]
* builder/hyper-v: Don't wait for shutdown_command to return. [GH-4691]
* builder/amazon: Fix b/c issue by reporting again the tags we create.
[GH-4704]
* builder/virtualbox: retry removing floppy controller. [GH-4705]
* builder/googlecompute: Correct values for `on_host_maintenance`. [GH-4643]
* builder/amazon: Fix crash in `step_region_copy`. [GH-4642]
### IMPROVEMENTS:
* More diligently try to complete azure-setup.sh. [GH-4752]
* builder/ansible: Clearer error message when we have problems getting the
ansible version. [GH-4694]
* builder/amazon-chroot: Ability to give an empty list in `copy_files` to
prevent the default `/etc/resolv.conf` file from being copied. If `copy_files`
isn't given at all, the default behavior remains. [GH-4708]
* builder/amazon: validate ssh key name/file. [GH-4665]
* builder/amazon: set force_deregister to true on -force. [GH-4649]
* builder/hyper-v: validate output dir in step, not in config. [GH-4645]
* website: fix display on ios devices. [GH-4618]
## 0.12.3 (March 1, 2017) ## 0.12.3 (March 1, 2017)
### BACKWARDS INCOMPATIBILITIES:
* provisioner/ansible: by default, the staging dir will be randomized. [GH-4472]
### FEATURES: ### FEATURES:
* **New builder:** `ebs-surrogate` for building AMIs from EBS volumes. [GH-4351] * **New builder:** `ebs-surrogate` for building AMIs from EBS volumes. [GH-4351]
@ -18,7 +63,6 @@
* communicator/winrm: support ProxyFromEnvironment. [GH-4463] * communicator/winrm: support ProxyFromEnvironment. [GH-4463]
* core: make VNC links clickable in terminal. [GH-4497] [GH-4498] * core: make VNC links clickable in terminal. [GH-4497] [GH-4498]
* post-processor/amazon-import: support AMI attributes on import [GH-4216] * post-processor/amazon-import: support AMI attributes on import [GH-4216]
* provisioner/ansible: use randomized staging dir [GH-4472]
* communicator/ssh: Use SSH agent when enabled for bastion step. [GH-4598] * communicator/ssh: Use SSH agent when enabled for bastion step. [GH-4598]
* builder/amazon: enable ena when `enhanced_networking` is set. [GH-4578] * builder/amazon: enable ena when `enhanced_networking` is set. [GH-4578]
* builder/vmware-esxi: try for longer to connect to vnc port. [GH-4480] * builder/vmware-esxi: try for longer to connect to vnc port. [GH-4480]
@ -32,7 +76,6 @@
* builder/azure:: add two new config variables for temp_compute_name and * builder/azure:: add two new config variables for temp_compute_name and
temp_resource_group_name. [GH-4468] temp_resource_group_name. [GH-4468]
### BUG FIXES: ### BUG FIXES:
* builder/amazon: Fix ssh agent authentication. [GH-4597] * builder/amazon: Fix ssh agent authentication. [GH-4597]

View File

@ -65,28 +65,28 @@ following steps in order to be able to compile and test Packer. These instructio
``` ```
3. Download the Packer source (and its dependencies) by running `go get 3. Download the Packer source (and its dependencies) by running `go get
github.com/mitchellh/packer`. This will download the Packer source to github.com/hashicorp/packer`. This will download the Packer source to
`$GOPATH/src/github.com/mitchellh/packer`. `$GOPATH/src/github.com/hashicorp/packer`.
4. When working on packer `cd $GOPATH/src/github.com/mitchellh/packer` so you 4. When working on packer `cd $GOPATH/src/github.com/hashicorp/packer` so you
can run `make` and easily access other files. Run `make help` to get can run `make` and easily access other files. Run `make help` to get
information about make targets. information about make targets.
5. Make your changes to the Packer source. You can run `make` in 5. Make your changes to the Packer source. You can run `make` in
`$GOPATH/src/github.com/mitchellh/packer` to run tests and build the packer `$GOPATH/src/github.com/hashicorp/packer` to run tests and build the packer
binary. Any compilation errors will be shown when the binaries are binary. Any compilation errors will be shown when the binaries are
rebuilding. If you don't have `make` you can simply run `go build -o bin/packer .` from the project root. rebuilding. If you don't have `make` you can simply run `go build -o bin/packer .` from the project root.
6. After running building packer successfully, use 6. After running building packer successfully, use
`$GOPATH/src/github.com/mitchellh/packer/bin/packer` to build a machine and `$GOPATH/src/github.com/hashicorp/packer/bin/packer` to build a machine and
verify your changes work. For instance: `$GOPATH/src/github.com/mitchellh/packer/bin/packer build template.json`. verify your changes work. For instance: `$GOPATH/src/github.com/hashicorp/packer/bin/packer build template.json`.
7. If everything works well and the tests pass, run `go fmt` on your code 7. If everything works well and the tests pass, run `go fmt` on your code
before submitting a pull-request. before submitting a pull-request.
### Opening an Pull Request ### Opening an Pull Request
When you are ready to open a pull-request, you will need to [fork packer](https://github.com/mitchellh/packer#fork-destination-box), push your changes to your fork, and then open a pull-request. When you are ready to open a pull-request, you will need to [fork packer](https://github.com/hashicorp/packer#fork-destination-box), push your changes to your fork, and then open a pull-request.
For example, my github username is `cbednarski` so I would do the following: For example, my github username is `cbednarski` so I would do the following:
@ -104,7 +104,7 @@ From there, open your fork in your browser to open a new pull-request.
The easiest way to work on a fork is to set it as a remote of the packer project. After following the steps in "Setting up Go to work on Packer": The easiest way to work on a fork is to set it as a remote of the packer project. After following the steps in "Setting up Go to work on Packer":
1. Navigate to $GOPATH/src/github.com/mitchellh/packer 1. Navigate to $GOPATH/src/github.com/hashicorp/packer
2. Add the remote `git remote add <name of remote> <github url of fork>`. For example `git remote add mwhooker https://github.com/mwhooker/packer.git`. 2. Add the remote `git remote add <name of remote> <github url of fork>`. For example `git remote add mwhooker https://github.com/mwhooker/packer.git`.
3. Checkout a feature branch: `git checkout -b new-feature` 3. Checkout a feature branch: `git checkout -b new-feature`
4. Make changes 4. Make changes

View File

@ -5,8 +5,8 @@
[![GoDoc][godoc-badge]][godoc] [![GoDoc][godoc-badge]][godoc]
[![GoReportCard][report-badge]][report] [![GoReportCard][report-badge]][report]
[travis-badge]: https://travis-ci.org/mitchellh/packer.svg?branch=master [travis-badge]: https://travis-ci.org/hashicorp/packer.svg?branch=master
[travis]: https://travis-ci.org/mitchellh/packer [travis]: https://travis-ci.org/hashicorp/packer
[appveyor-badge]: https://ci.appveyor.com/api/projects/status/github/mitchellh/packer?branch=master&svg=true [appveyor-badge]: https://ci.appveyor.com/api/projects/status/github/mitchellh/packer?branch=master&svg=true
[appveyor]: https://ci.appveyor.com/project/hashicorp/packer [appveyor]: https://ci.appveyor.com/project/hashicorp/packer
[godoc-badge]: https://godoc.org/github.com/mitchellh/packer?status.svg [godoc-badge]: https://godoc.org/github.com/mitchellh/packer?status.svg
@ -14,7 +14,7 @@
[report-badge]: https://goreportcard.com/badge/github.com/mitchellh/packer [report-badge]: https://goreportcard.com/badge/github.com/mitchellh/packer
[report]: https://goreportcard.com/report/github.com/mitchellh/packer [report]: https://goreportcard.com/report/github.com/mitchellh/packer
* Website: http://www.packer.io * Website: https://www.packer.io
* IRC: `#packer-tool` on Freenode * IRC: `#packer-tool` on Freenode
* Mailing list: [Google Groups](http://groups.google.com/group/packer-tool) * Mailing list: [Google Groups](http://groups.google.com/group/packer-tool)
@ -27,14 +27,19 @@ comes out of the box with support for the following platforms:
* Amazon EC2 (AMI). Both EBS-backed and instance-store AMIs * Amazon EC2 (AMI). Both EBS-backed and instance-store AMIs
* Azure * Azure
* CloudStack
* DigitalOcean * DigitalOcean
* Docker * Docker
* Google Compute Engine * Google Compute Engine
* Hyper-V
* 1&1
* OpenStack * OpenStack
* Parallels * Parallels
* ProfitBricks
* QEMU. Both KVM and Xen images. * QEMU. Both KVM and Xen images.
* VirtualBox * Triton (Joyent Public Cloud)
* VMware * VMware
* VirtualBox
Support for other platforms can be added via plugins. Support for other platforms can be added via plugins.
@ -44,7 +49,7 @@ The images that Packer creates can easily be turned into
## Quick Start ## Quick Start
Download and install packages and dependencies Download and install packages and dependencies
``` ```
go get github.com/mitchellh/packer go get github.com/hashicorp/packer
``` ```
**Note:** There is a great **Note:** There is a great
@ -102,4 +107,4 @@ http://www.packer.io/docs
## Developing Packer ## Developing Packer
See [CONTRIBUTING.md](https://github.com/mitchellh/packer/blob/master/CONTRIBUTING.md) for best practices and instructions on setting up your development environment to work on Packer. See [CONTRIBUTING.md](https://github.com/hashicorp/packer/blob/master/CONTRIBUTING.md) for best practices and instructions on setting up your development environment to work on Packer.

View File

@ -29,9 +29,9 @@ build_script:
- ps: | - ps: |
go.exe test (go.exe list ./... ` go.exe test (go.exe list ./... `
|? { -not $_.Contains('/vendor/') } ` |? { -not $_.Contains('/vendor/') } `
|? { $_ -ne 'github.com/mitchellh/packer/builder/parallels/common' } ` |? { $_ -ne 'github.com/hashicorp/packer/builder/parallels/common' } `
|? { $_ -ne 'github.com/mitchellh/packer/common' }` |? { $_ -ne 'github.com/hashicorp/packer/common' }`
|? { $_ -ne 'github.com/mitchellh/packer/provisioner/ansible' }) |? { $_ -ne 'github.com/hashicorp/packer/provisioner/ansible' })
test: off test: off

View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/common"
"github.com/denverdino/aliyungo/ecs" "github.com/denverdino/aliyungo/ecs"
"github.com/mitchellh/packer/template/interpolate" "github.com/hashicorp/packer/template/interpolate"
"os" "os"
) )

View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/common"
"github.com/denverdino/aliyungo/ecs" "github.com/denverdino/aliyungo/ecs"
"github.com/mitchellh/packer/packer" "github.com/hashicorp/packer/packer"
"log" "log"
"sort" "sort"
"strings" "strings"

View File

@ -4,7 +4,7 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/mitchellh/packer/packer" "github.com/hashicorp/packer/packer"
) )
func TestArtifact_Impl(t *testing.T) { func TestArtifact_Impl(t *testing.T) {

View File

@ -3,7 +3,7 @@ package ecs
import ( import (
"fmt" "fmt"
"github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/common"
"github.com/mitchellh/packer/template/interpolate" "github.com/hashicorp/packer/template/interpolate"
) )
type AlicloudDiskDevice struct { type AlicloudDiskDevice struct {

View File

@ -2,8 +2,8 @@ package ecs
import ( import (
"fmt" "fmt"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
func message(state multistep.StateBag, module string) { func message(state multistep.StateBag, module string) {

View File

@ -3,9 +3,9 @@ package ecs
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/mitchellh/packer/common/uuid" "github.com/hashicorp/packer/common/uuid"
"github.com/mitchellh/packer/helper/communicator" "github.com/hashicorp/packer/helper/communicator"
"github.com/mitchellh/packer/template/interpolate" "github.com/hashicorp/packer/template/interpolate"
"os" "os"
) )
@ -40,7 +40,7 @@ type RunConfig struct {
func (c *RunConfig) Prepare(ctx *interpolate.Context) []error { func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
if c.SSHKeyPairName == "" && c.TemporaryKeyPairName == "" && if c.SSHKeyPairName == "" && c.TemporaryKeyPairName == "" &&
c.Comm.SSHPrivateKey == "" && c.Comm.SSHPassword == "" { c.Comm.SSHPrivateKey == "" && c.Comm.SSHPassword == "" && c.Comm.WinRMPassword == "" {
c.TemporaryKeyPairName = fmt.Sprintf("packer_%s", uuid.TimeOrderedUUID()) c.TemporaryKeyPairName = fmt.Sprintf("packer_%s", uuid.TimeOrderedUUID())
} }

View File

@ -4,7 +4,7 @@ import (
"io/ioutil" "io/ioutil"
"testing" "testing"
"github.com/mitchellh/packer/helper/communicator" "github.com/hashicorp/packer/helper/communicator"
) )
func testConfig() *RunConfig { func testConfig() *RunConfig {

View File

@ -2,8 +2,8 @@ package ecs
import ( import (
"fmt" "fmt"
packerssh "github.com/hashicorp/packer/communicator/ssh"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
packerssh "github.com/mitchellh/packer/communicator/ssh"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/agent" "golang.org/x/crypto/ssh/agent"
"net" "net"

View File

@ -3,12 +3,12 @@
package ecs package ecs
import ( import (
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/helper/config"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/helper/communicator"
"github.com/mitchellh/packer/helper/config"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template/interpolate"
"log" "log"
) )

View File

@ -7,8 +7,8 @@ import (
"fmt" "fmt"
"github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/common"
"github.com/denverdino/aliyungo/ecs" "github.com/denverdino/aliyungo/ecs"
builderT "github.com/mitchellh/packer/helper/builder/testing" builderT "github.com/hashicorp/packer/helper/builder/testing"
"github.com/mitchellh/packer/packer" "github.com/hashicorp/packer/packer"
) )
func TestBuilderAcc_basic(t *testing.T) { func TestBuilderAcc_basic(t *testing.T) {
@ -313,7 +313,7 @@ const testBuilderAccWindows = `
"type": "test", "type": "test",
"region": "cn-beijing", "region": "cn-beijing",
"instance_type": "ecs.n1.tiny", "instance_type": "ecs.n1.tiny",
"source_image":"win2008_64_ent_r2_zh-cn_40G_alibase_20170118.vhd", "source_image":"win2008_64_ent_r2_zh-cn_40G_alibase_20170301.vhd",
"io_optimized":"true", "io_optimized":"true",
"image_force_delete":"true", "image_force_delete":"true",
"communicator": "winrm", "communicator": "winrm",

View File

@ -3,7 +3,7 @@ package ecs
import ( import (
"testing" "testing"
"github.com/mitchellh/packer/packer" "github.com/hashicorp/packer/packer"
) )
func testBuilderConfig() map[string]interface{} { func testBuilderConfig() map[string]interface{} {

View File

@ -4,8 +4,8 @@ import (
"fmt" "fmt"
"github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/common"
"github.com/denverdino/aliyungo/ecs" "github.com/denverdino/aliyungo/ecs"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
type stepCheckAlicloudSourceImage struct { type stepCheckAlicloudSourceImage struct {

View File

@ -4,8 +4,8 @@ import (
"fmt" "fmt"
"github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/common"
"github.com/denverdino/aliyungo/ecs" "github.com/denverdino/aliyungo/ecs"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
type setpConfigAlicloudEIP struct { type setpConfigAlicloudEIP struct {

View File

@ -2,8 +2,8 @@ package ecs
import ( import (
"fmt" "fmt"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"io/ioutil" "io/ioutil"
) )

View File

@ -3,8 +3,8 @@ package ecs
import ( import (
"fmt" "fmt"
"github.com/denverdino/aliyungo/ecs" "github.com/denverdino/aliyungo/ecs"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
type stepConfigAlicloudPublicIP struct { type stepConfigAlicloudPublicIP struct {

View File

@ -5,8 +5,8 @@ import (
"fmt" "fmt"
"github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/common"
"github.com/denverdino/aliyungo/ecs" "github.com/denverdino/aliyungo/ecs"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"time" "time"
) )

View File

@ -5,8 +5,8 @@ import (
"fmt" "fmt"
"github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/common"
"github.com/denverdino/aliyungo/ecs" "github.com/denverdino/aliyungo/ecs"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"time" "time"
) )

View File

@ -5,8 +5,8 @@ import (
"fmt" "fmt"
"github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/common"
"github.com/denverdino/aliyungo/ecs" "github.com/denverdino/aliyungo/ecs"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"time" "time"
) )

View File

@ -4,8 +4,8 @@ import (
"fmt" "fmt"
"github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/common"
"github.com/denverdino/aliyungo/ecs" "github.com/denverdino/aliyungo/ecs"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
type stepCreateAlicloudImage struct { type stepCreateAlicloudImage struct {

View File

@ -4,8 +4,8 @@ import (
"fmt" "fmt"
"github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/common"
"github.com/denverdino/aliyungo/ecs" "github.com/denverdino/aliyungo/ecs"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"io/ioutil" "io/ioutil"
"log" "log"
"strings" "strings"

View File

@ -4,8 +4,8 @@ import (
"fmt" "fmt"
"github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/common"
"github.com/denverdino/aliyungo/ecs" "github.com/denverdino/aliyungo/ecs"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"log" "log"
) )

View File

@ -3,8 +3,8 @@ package ecs
import ( import (
"fmt" "fmt"
"github.com/denverdino/aliyungo/ecs" "github.com/denverdino/aliyungo/ecs"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
type stepMountAlicloudDisk struct { type stepMountAlicloudDisk struct {

View File

@ -4,8 +4,8 @@ import (
"fmt" "fmt"
"github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/common"
"github.com/denverdino/aliyungo/ecs" "github.com/denverdino/aliyungo/ecs"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
type stepPreValidate struct { type stepPreValidate struct {

View File

@ -4,8 +4,8 @@ import (
"fmt" "fmt"
"github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/common"
"github.com/denverdino/aliyungo/ecs" "github.com/denverdino/aliyungo/ecs"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
type setpRegionCopyAlicloudImage struct { type setpRegionCopyAlicloudImage struct {

View File

@ -3,8 +3,8 @@ package ecs
import ( import (
"fmt" "fmt"
"github.com/denverdino/aliyungo/ecs" "github.com/denverdino/aliyungo/ecs"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
type stepRunAlicloudInstance struct { type stepRunAlicloudInstance struct {

View File

@ -4,8 +4,8 @@ import (
"fmt" "fmt"
"github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/common"
"github.com/denverdino/aliyungo/ecs" "github.com/denverdino/aliyungo/ecs"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
type setpShareAlicloudImage struct { type setpShareAlicloudImage struct {

View File

@ -3,8 +3,8 @@ package ecs
import ( import (
"fmt" "fmt"
"github.com/denverdino/aliyungo/ecs" "github.com/denverdino/aliyungo/ecs"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
type stepStopAlicloudInstance struct { type stepStopAlicloudInstance struct {

View File

@ -11,12 +11,12 @@ import (
"github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/config"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
awscommon "github.com/mitchellh/packer/builder/amazon/common"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/helper/config"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template/interpolate"
) )
// The unique ID for this builder // The unique ID for this builder
@ -78,15 +78,15 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
return nil, err return nil, err
} }
if b.config.PackerConfig.PackerForce {
b.config.AMIForceDeregister = true
}
// Defaults // Defaults
if b.config.ChrootMounts == nil { if b.config.ChrootMounts == nil {
b.config.ChrootMounts = make([][]string, 0) b.config.ChrootMounts = make([][]string, 0)
} }
if b.config.CopyFiles == nil {
b.config.CopyFiles = make([]string, 0)
}
if len(b.config.ChrootMounts) == 0 { if len(b.config.ChrootMounts) == 0 {
b.config.ChrootMounts = [][]string{ b.config.ChrootMounts = [][]string{
{"proc", "proc", "/proc"}, {"proc", "proc", "/proc"},
@ -97,9 +97,13 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
} }
} }
if len(b.config.CopyFiles) == 0 && !b.config.FromScratch { // set default copy file if we're not giving our own
if b.config.CopyFiles == nil {
b.config.CopyFiles = make([]string, 0)
if !b.config.FromScratch {
b.config.CopyFiles = []string{"/etc/resolv.conf"} b.config.CopyFiles = []string{"/etc/resolv.conf"}
} }
}
if b.config.CommandWrapper == "" { if b.config.CommandWrapper == "" {
b.config.CommandWrapper = "{{.Command}}" b.config.CommandWrapper = "{{.Command}}"

View File

@ -1,8 +1,9 @@
package chroot package chroot
import ( import (
"github.com/mitchellh/packer/packer"
"testing" "testing"
"github.com/hashicorp/packer/packer"
) )
func testConfig() map[string]interface{} { func testConfig() map[string]interface{} {
@ -117,3 +118,33 @@ func TestBuilderPrepare_CommandWrapper(t *testing.T) {
t.Errorf("err: %s", err) t.Errorf("err: %s", err)
} }
} }
func TestBuilderPrepare_CopyFiles(t *testing.T) {
b := &Builder{}
config := testConfig()
warnings, err := b.Prepare(config)
if len(warnings) > 0 {
t.Fatalf("bad: %#v", warnings)
}
if err != nil {
t.Errorf("err: %s", err)
}
if len(b.config.CopyFiles) != 1 && b.config.CopyFiles[0] != "/etc/resolv.conf" {
t.Errorf("Was expecting default value for copy_files.")
}
config["copy_files"] = []string{}
warnings, err = b.Prepare(config)
if len(warnings) > 0 {
t.Fatalf("bad: %#v", warnings)
}
if err != nil {
t.Errorf("err: %s", err)
}
if len(b.config.CopyFiles) > 0 {
t.Errorf("Was expecting no default value for copy_files.")
}
}

View File

@ -12,7 +12,7 @@ import (
"strings" "strings"
"syscall" "syscall"
"github.com/mitchellh/packer/packer" "github.com/hashicorp/packer/packer"
) )
// Communicator is a special communicator that works by executing // Communicator is a special communicator that works by executing
@ -69,7 +69,10 @@ func (c *Communicator) Upload(dst string, r io.Reader, fi *os.FileInfo) error {
return fmt.Errorf("Error preparing shell script: %s", err) return fmt.Errorf("Error preparing shell script: %s", err)
} }
defer os.Remove(tf.Name()) defer os.Remove(tf.Name())
io.Copy(tf, r)
if _, err := io.Copy(tf, r); err != nil {
return err
}
cpCmd, err := c.CmdWrapper(fmt.Sprintf("cp %s %s", tf.Name(), dst)) cpCmd, err := c.CmdWrapper(fmt.Sprintf("cp %s %s", tf.Name(), dst))
if err != nil { if err != nil {

View File

@ -1,7 +1,7 @@
package chroot package chroot
import ( import (
"github.com/mitchellh/packer/packer" "github.com/hashicorp/packer/packer"
"testing" "testing"
) )

View File

@ -3,9 +3,9 @@ package chroot
import ( import (
"fmt" "fmt"
"github.com/mitchellh/packer/packer" "github.com/hashicorp/packer/packer"
"github.com/mitchellh/packer/post-processor/shell-local" "github.com/hashicorp/packer/post-processor/shell-local"
"github.com/mitchellh/packer/template/interpolate" "github.com/hashicorp/packer/template/interpolate"
) )
func RunLocalCommands(commands []string, wrappedCommand CommandWrapper, ctx interpolate.Context, ui packer.Ui) error { func RunLocalCommands(commands []string, wrappedCommand CommandWrapper, ctx interpolate.Context, ui packer.Ui) error {

View File

@ -7,9 +7,9 @@ import (
"time" "time"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
awscommon "github.com/mitchellh/packer/builder/amazon/common"
"github.com/mitchellh/packer/packer"
) )
// StepAttachVolume attaches the previously created volume to an // StepAttachVolume attaches the previously created volume to an

View File

@ -4,8 +4,8 @@ import (
"fmt" "fmt"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
// StepCheckRootDevice makes sure the root device on the AMI is EBS-backed. // StepCheckRootDevice makes sure the root device on the AMI is EBS-backed.

View File

@ -1,14 +1,14 @@
package chroot package chroot
import ( import (
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"log" "log"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep"
) )
// StepChrootProvision provisions the instance within a chroot. // StepChrootProvision provisions the instance within a chroot.
type StepChrootProvision struct { type StepChrootProvision struct {
mounts []string
} }
func (s *StepChrootProvision) Run(state multistep.StateBag) multistep.StepAction { func (s *StepChrootProvision) Run(state multistep.StateBag) multistep.StepAction {

View File

@ -3,8 +3,8 @@ package chroot
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"log" "log"
"path/filepath" "path/filepath"
) )

View File

@ -6,9 +6,9 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
awscommon "github.com/mitchellh/packer/builder/amazon/common"
"github.com/mitchellh/packer/packer"
) )
// StepCreateVolume creates a new volume from the snapshot of the root // StepCreateVolume creates a new volume from the snapshot of the root

View File

@ -2,8 +2,8 @@ package chroot
import ( import (
"fmt" "fmt"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"log" "log"
) )

View File

@ -2,8 +2,8 @@ package chroot
import ( import (
"fmt" "fmt"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"log" "log"
) )

View File

@ -2,8 +2,8 @@ package chroot
import ( import (
"fmt" "fmt"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"log" "log"
"os" "os"
"path/filepath" "path/filepath"

View File

@ -5,9 +5,9 @@ import (
"log" "log"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/builder/amazon/common"
"github.com/mitchellh/packer/packer"
) )
// StepInstanceInfo verifies that this builder is running on an EC2 instance. // StepInstanceInfo verifies that this builder is running on an EC2 instance.

View File

@ -9,9 +9,9 @@ import (
"strings" "strings"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template/interpolate"
) )
type mountPathData struct { type mountPathData struct {
@ -82,7 +82,7 @@ func (s *StepMountDevice) Run(state multistep.StateBag) multistep.StepAction {
ui.Say("Mounting the root device...") ui.Say("Mounting the root device...")
stderr := new(bytes.Buffer) stderr := new(bytes.Buffer)
// build mount options from mount_options config, usefull for nouuid options // build mount options from mount_options config, useful for nouuid options
// or other specific device type settings for mount // or other specific device type settings for mount
opts := "" opts := ""
if len(s.MountOptions) > 0 { if len(s.MountOptions) > 0 {

View File

@ -3,8 +3,8 @@ package chroot
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"os" "os"
"os/exec" "os/exec"
"syscall" "syscall"

View File

@ -1,8 +1,8 @@
package chroot package chroot
import ( import (
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
type postMountCommandsData struct { type postMountCommandsData struct {

View File

@ -1,8 +1,8 @@
package chroot package chroot
import ( import (
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
type preMountCommandsData struct { type preMountCommandsData struct {

View File

@ -2,15 +2,15 @@ package chroot
import ( import (
"fmt" "fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"log" "log"
"os" "os"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep"
) )
// StepPrepareDevice finds an available device and sets it. // StepPrepareDevice finds an available device and sets it.
type StepPrepareDevice struct { type StepPrepareDevice struct {
mounts []string
} }
func (s *StepPrepareDevice) Run(state multistep.StateBag) multistep.StepAction { func (s *StepPrepareDevice) Run(state multistep.StateBag) multistep.StepAction {

View File

@ -5,9 +5,9 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
awscommon "github.com/mitchellh/packer/builder/amazon/common"
"github.com/mitchellh/packer/packer"
) )
// StepRegisterAMI creates the AMI. // StepRegisterAMI creates the AMI.

View File

@ -6,9 +6,9 @@ import (
"time" "time"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
awscommon "github.com/mitchellh/packer/builder/amazon/common"
"github.com/mitchellh/packer/packer"
) )
// StepSnapshot creates a snapshot of the created volume. // StepSnapshot creates a snapshot of the created volume.

View File

@ -12,7 +12,7 @@ import (
"github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds" "github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds"
"github.com/aws/aws-sdk-go/aws/ec2metadata" "github.com/aws/aws-sdk-go/aws/ec2metadata"
"github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/aws/session"
"github.com/mitchellh/packer/template/interpolate" "github.com/hashicorp/packer/template/interpolate"
) )
// AccessConfig is for common configuration related to AWS access // AccessConfig is for common configuration related to AWS access
@ -66,7 +66,7 @@ func (c *AccessConfig) Config() (*aws.Config, error) {
func (c *AccessConfig) Region() (string, error) { func (c *AccessConfig) Region() (string, error) {
if c.RawRegion != "" { if c.RawRegion != "" {
if !c.SkipValidation { if !c.SkipValidation {
if valid := ValidateRegion(c.RawRegion); valid == false { if valid := ValidateRegion(c.RawRegion); !valid {
return "", fmt.Errorf("Not a valid region: %s", c.RawRegion) return "", fmt.Errorf("Not a valid region: %s", c.RawRegion)
} }
} }
@ -85,7 +85,7 @@ func (c *AccessConfig) Region() (string, error) {
func (c *AccessConfig) Prepare(ctx *interpolate.Context) []error { func (c *AccessConfig) Prepare(ctx *interpolate.Context) []error {
var errs []error var errs []error
if c.RawRegion != "" && !c.SkipValidation { if c.RawRegion != "" && !c.SkipValidation {
if valid := ValidateRegion(c.RawRegion); valid == false { if valid := ValidateRegion(c.RawRegion); !valid {
errs = append(errs, fmt.Errorf("Unknown region: %s", c.RawRegion)) errs = append(errs, fmt.Errorf("Unknown region: %s", c.RawRegion))
} }
} }
@ -115,5 +115,5 @@ func GetInstanceMetaData(path string) (contents []byte, err error) {
if err != nil { if err != nil {
return return
} }
return []byte(body), err return body, err
} }

View File

@ -2,8 +2,9 @@ package common
import ( import (
"fmt" "fmt"
"regexp"
"github.com/mitchellh/packer/template/interpolate" "github.com/hashicorp/packer/template/interpolate"
) )
// AMIConfig is for common configuration related to creating AMIs. // AMIConfig is for common configuration related to creating AMIs.
@ -48,7 +49,7 @@ func (c *AMIConfig) Prepare(ctx *interpolate.Context) []error {
if !c.AMISkipRegionValidation { if !c.AMISkipRegionValidation {
// Verify the region is real // Verify the region is real
if valid := ValidateRegion(region); valid == false { if valid := ValidateRegion(region); !valid {
errs = append(errs, fmt.Errorf("Unknown region: %s", region)) errs = append(errs, fmt.Errorf("Unknown region: %s", region))
continue continue
} }
@ -68,6 +69,18 @@ func (c *AMIConfig) Prepare(ctx *interpolate.Context) []error {
errs = append(errs, fmt.Errorf("Cannot share snapshot encrypted with default KMS key")) errs = append(errs, fmt.Errorf("Cannot share snapshot encrypted with default KMS key"))
} }
if len(c.AMIName) < 3 || len(c.AMIName) > 128 {
errs = append(errs, fmt.Errorf("AMIName must be between 3 and 128 characters long"))
}
amiNameRe := regexp.MustCompile(`^[0-9a-zA-Z().\-/_]+$`)
if !amiNameRe.MatchString(c.AMIName) {
errs = append(errs, fmt.Errorf("AMIName should only contain letters,"+
" numbers, '(', ')', '.', '-', '/' and '_'. You can use the "+
"`clean_ami_name` template filter to automatically clean your ami "+
"name."))
}
if len(errs) > 0 { if len(errs) > 0 {
return errs return errs
} }

View File

@ -74,3 +74,37 @@ func TestAMIConfigPrepare_Share_EncryptedBoot(t *testing.T) {
t.Fatal("shouldn't be able to share ami with encrypted boot volume") t.Fatal("shouldn't be able to share ami with encrypted boot volume")
} }
} }
func TestAMINameValidation(t *testing.T) {
c := testAMIConfig()
c.AMIName = "aa"
if err := c.Prepare(nil); err == nil {
t.Fatal("shouldn't be able to have an ami name with less than 3 characters")
}
var longAmiName string
for i := 0; i < 129; i++ {
longAmiName += "a"
}
c.AMIName = longAmiName
if err := c.Prepare(nil); err == nil {
t.Fatal("shouldn't be able to have an ami name with great than 128 characters")
}
c.AMIName = "+aaa"
if err := c.Prepare(nil); err == nil {
t.Fatal("shouldn't be able to have an ami name with invalid characters")
}
c.AMIName = "foo().-/_bar"
if err := c.Prepare(nil); err != nil {
t.Fatal("expected 'foobar' to be a valid ami name")
}
c.AMIName = `xyz-base-2017-04-05-1934`
if err := c.Prepare(nil); err != nil {
t.Fatalf("expected `xyz-base-2017-04-05-1934` to pass validation.")
}
}

View File

@ -9,7 +9,7 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/mitchellh/packer/packer" "github.com/hashicorp/packer/packer"
) )
// Artifact is an artifact implementation that contains built AMIs. // Artifact is an artifact implementation that contains built AMIs.

View File

@ -4,7 +4,7 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/mitchellh/packer/packer" "github.com/hashicorp/packer/packer"
) )
func TestArtifact_Impl(t *testing.T) { func TestArtifact_Impl(t *testing.T) {

View File

@ -5,7 +5,7 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/mitchellh/packer/template/interpolate" "github.com/hashicorp/packer/template/interpolate"
) )
// BlockDevice // BlockDevice

View File

@ -90,11 +90,8 @@ func (c *CLIConfig) Prepare(name string) error {
c.SourceProfile = c.ProfileName c.SourceProfile = c.ProfileName
} }
c.profileCred, err = credsFromName(c.SourceProfile) c.profileCred, err = credsFromName(c.SourceProfile)
if err != nil {
return err return err
} }
return nil
}
func (c *CLIConfig) getSessionName(rawName string) (string, error) { func (c *CLIConfig) getSessionName(rawName string) (string, error) {
if rawName == "" { if rawName == "" {

View File

@ -7,9 +7,9 @@ import (
"regexp" "regexp"
"time" "time"
"github.com/mitchellh/packer/common/uuid" "github.com/hashicorp/packer/common/uuid"
"github.com/mitchellh/packer/helper/communicator" "github.com/hashicorp/packer/helper/communicator"
"github.com/mitchellh/packer/template/interpolate" "github.com/hashicorp/packer/template/interpolate"
) )
var reShutdownBehavior = regexp.MustCompile("^(stop|terminate)$") var reShutdownBehavior = regexp.MustCompile("^(stop|terminate)$")
@ -75,6 +75,14 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
// Validation // Validation
errs := c.Comm.Prepare(ctx) errs := c.Comm.Prepare(ctx)
if c.SSHKeyPairName != "" {
if c.Comm.Type == "winrm" && c.Comm.WinRMPassword == "" && c.Comm.SSHPrivateKey == "" {
errs = append(errs, errors.New("A private_key_file must be provided to retrieve the winrm password when using ssh_keypair_name."))
} else if c.Comm.SSHPrivateKey == "" && !c.Comm.SSHAgentAuth {
errs = append(errs, errors.New("A private_key_file must be provided or ssh_agent_auth enabled when ssh_keypair_name is specified."))
}
}
if c.SourceAmi == "" && c.SourceAmiFilter.Empty() { if c.SourceAmi == "" && c.SourceAmiFilter.Empty() {
errs = append(errs, errors.New("A source_ami or source_ami_filter must be specified")) errs = append(errs, errors.New("A source_ami or source_ami_filter must be specified"))
} }

View File

@ -6,7 +6,7 @@ import (
"regexp" "regexp"
"testing" "testing"
"github.com/mitchellh/packer/helper/communicator" "github.com/hashicorp/packer/helper/communicator"
) )
func init() { func init() {

View File

@ -8,8 +8,8 @@ import (
"time" "time"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
packerssh "github.com/hashicorp/packer/communicator/ssh"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
packerssh "github.com/mitchellh/packer/communicator/ssh"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/agent" "golang.org/x/crypto/ssh/agent"
) )

View File

@ -163,7 +163,7 @@ func WaitForState(conf *StateChangeConf) (i interface{}, err error) {
log.Printf("Waiting for state to become: %s", conf.Target) log.Printf("Waiting for state to become: %s", conf.Target)
sleepSeconds := SleepSeconds() sleepSeconds := SleepSeconds()
maxTicks := int(TimeoutSeconds()/sleepSeconds) + 1 maxTicks := TimeoutSeconds()/sleepSeconds + 1
notfoundTick := 0 notfoundTick := 0
for { for {

View File

@ -2,15 +2,14 @@ package common
import ( import (
"fmt" "fmt"
"sync" "sync"
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
type StepAMIRegionCopy struct { type StepAMIRegionCopy struct {
@ -128,7 +127,7 @@ func amiRegionCopy(state multistep.StateBag, config *AccessConfig, name string,
} }
for _, blockDeviceMapping := range describeImageResp.Images[0].BlockDeviceMappings { for _, blockDeviceMapping := range describeImageResp.Images[0].BlockDeviceMappings {
if blockDeviceMapping.Ebs != nil { if blockDeviceMapping.Ebs != nil && blockDeviceMapping.Ebs.SnapshotId != nil {
snapshotIds = append(snapshotIds, *blockDeviceMapping.Ebs.SnapshotId) snapshotIds = append(snapshotIds, *blockDeviceMapping.Ebs.SnapshotId)
} }
} }

View File

@ -2,16 +2,15 @@ package common
import ( import (
"fmt" "fmt"
"log"
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
retry "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
retry "github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template/interpolate"
) )
type StepCreateTags struct { type StepCreateTags struct {
@ -94,6 +93,7 @@ func (s *StepCreateTags) Run(state multistep.StateBag) multistep.StepAction {
ui.Error(err.Error()) ui.Error(err.Error())
return multistep.ActionHalt return multistep.ActionHalt
} }
ReportTags(ui, amiTags)
ui.Say("Creating snapshot tags") ui.Say("Creating snapshot tags")
snapshotTags, err := ConvertToEC2Tags(s.SnapshotTags, *ec2conn.Config.Region, sourceAMI, s.Ctx) snapshotTags, err := ConvertToEC2Tags(s.SnapshotTags, *ec2conn.Config.Region, sourceAMI, s.Ctx)
@ -102,6 +102,7 @@ func (s *StepCreateTags) Run(state multistep.StateBag) multistep.StepAction {
ui.Error(err.Error()) ui.Error(err.Error())
return multistep.ActionHalt return multistep.ActionHalt
} }
ReportTags(ui, snapshotTags)
// Retry creating tags for about 2.5 minutes // Retry creating tags for about 2.5 minutes
err = retry.Retry(0.2, 30, 11, func() (bool, error) { err = retry.Retry(0.2, 30, 11, func() (bool, error) {
@ -150,6 +151,13 @@ func (s *StepCreateTags) Cleanup(state multistep.StateBag) {
// No cleanup... // No cleanup...
} }
func ReportTags(ui packer.Ui, tags []*ec2.Tag) {
for _, tag := range tags {
ui.Message(fmt.Sprintf("Adding tag: \"%s\": \"%s\"",
aws.StringValue(tag.Key), aws.StringValue(tag.Value)))
}
}
func ConvertToEC2Tags(tags map[string]string, region, sourceAmiId string, ctx interpolate.Context) ([]*ec2.Tag, error) { func ConvertToEC2Tags(tags map[string]string, region, sourceAmiId string, ctx interpolate.Context) ([]*ec2.Tag, error) {
var ec2Tags []*ec2.Tag var ec2Tags []*ec2.Tag
for key, value := range tags { for key, value := range tags {
@ -163,7 +171,6 @@ func ConvertToEC2Tags(tags map[string]string, region, sourceAmiId string, ctx in
return ec2Tags, fmt.Errorf("Error processing tag: %s:%s - %s", key, value, err) return ec2Tags, fmt.Errorf("Error processing tag: %s:%s - %s", key, value, err)
} }
log.Printf("Adding tag: \"%s\": \"%s\"", key, interpolatedValue)
ec2Tags = append(ec2Tags, &ec2.Tag{ ec2Tags = append(ec2Tags, &ec2.Tag{
Key: aws.String(key), Key: aws.String(key),
Value: aws.String(interpolatedValue), Value: aws.String(interpolatedValue),

View File

@ -5,8 +5,8 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
type StepDeregisterAMI struct { type StepDeregisterAMI struct {

View File

@ -6,8 +6,8 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
type StepCreateEncryptedAMICopy struct { type StepCreateEncryptedAMICopy struct {
@ -25,7 +25,7 @@ func (s *StepCreateEncryptedAMICopy) Run(state multistep.StateBag) multistep.Ste
// Encrypt boot not set, so skip step // Encrypt boot not set, so skip step
if !s.EncryptBootVolume { if !s.EncryptBootVolume {
if kmsKeyId != "" { if kmsKeyId != "" {
log.Printf(fmt.Sprintf("Ignoring KMS Key ID: %s, encrypted=false", kmsKeyId)) log.Printf("Ignoring KMS Key ID: %s, encrypted=false", kmsKeyId)
} }
return multistep.ActionContinue return multistep.ActionContinue
} }

View File

@ -11,9 +11,9 @@ import (
"time" "time"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/helper/communicator"
"github.com/mitchellh/packer/packer"
) )
// StepGetPassword reads the password from a Windows server and sets it // StepGetPassword reads the password from a Windows server and sets it

View File

@ -7,8 +7,8 @@ import (
"runtime" "runtime"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
type StepKeyPair struct { type StepKeyPair struct {

View File

@ -6,9 +6,9 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template/interpolate"
) )
type StepModifyAMIAttributes struct { type StepModifyAMIAttributes struct {

View File

@ -5,8 +5,8 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
type StepModifyEBSBackedInstance struct { type StepModifyEBSBackedInstance struct {

View File

@ -5,8 +5,8 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
// StepPreValidate provides an opportunity to pre-validate any configuration for // StepPreValidate provides an opportunity to pre-validate any configuration for

View File

@ -11,9 +11,9 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template/interpolate"
) )
type StepRunSourceInstance struct { type StepRunSourceInstance struct {
@ -289,6 +289,8 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
return multistep.ActionHalt return multistep.ActionHalt
} }
ReportTags(ui, ec2Tags)
_, err = ec2conn.CreateTags(&ec2.CreateTagsInput{ _, err = ec2conn.CreateTags(&ec2.CreateTagsInput{
Tags: ec2Tags, Tags: ec2Tags,
Resources: []*string{instance.InstanceId}, Resources: []*string{instance.InstanceId},
@ -340,7 +342,10 @@ func (s *StepRunSourceInstance) Cleanup(state multistep.StateBag) {
Target: "cancelled", Target: "cancelled",
} }
WaitForState(&stateChange) _, err := WaitForState(&stateChange)
if err != nil {
ui.Error(err.Error())
}
} }
@ -357,6 +362,9 @@ func (s *StepRunSourceInstance) Cleanup(state multistep.StateBag) {
Target: "terminated", Target: "terminated",
} }
WaitForState(&stateChange) _, err := WaitForState(&stateChange)
if err != nil {
ui.Error(err.Error())
}
} }
} }

View File

@ -8,10 +8,10 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/private/waiter" "github.com/aws/aws-sdk-go/private/waiter"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/common/uuid"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/common/uuid"
"github.com/mitchellh/packer/helper/communicator"
"github.com/mitchellh/packer/packer"
) )
type StepSecurityGroup struct { type StepSecurityGroup struct {
@ -77,7 +77,7 @@ func (s *StepSecurityGroup) Run(state multistep.StateBag) multistep.StepAction {
} }
// We loop and retry this a few times because sometimes the security // We loop and retry this a few times because sometimes the security
// group isn't available immediately because AWS resources are eventaully // group isn't available immediately because AWS resources are eventually
// consistent. // consistent.
ui.Say(fmt.Sprintf( ui.Say(fmt.Sprintf(
"Authorizing access to port %d the temporary security group...", "Authorizing access to port %d the temporary security group...",

View File

@ -7,8 +7,8 @@ import (
"time" "time"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
// StepSourceAMIInfo extracts critical information from the source AMI // StepSourceAMIInfo extracts critical information from the source AMI
@ -85,7 +85,7 @@ func (s *StepSourceAMIInfo) Run(state multistep.StateBag) multistep.StepAction {
return multistep.ActionHalt return multistep.ActionHalt
} }
if len(imageResp.Images) > 1 && s.AmiFilters.MostRecent == false { if len(imageResp.Images) > 1 && !s.AmiFilters.MostRecent {
err := fmt.Errorf("Your query returned more than one result. Please try a more specific search, or set most_recent to true.") err := fmt.Errorf("Your query returned more than one result. Please try a more specific search, or set most_recent to true.")
state.Put("error", err) state.Put("error", err)
ui.Error(err.Error()) ui.Error(err.Error())

View File

@ -4,8 +4,8 @@ import (
"fmt" "fmt"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
) )
type StepStopEBSBackedInstance struct { type StepStopEBSBackedInstance struct {

View File

@ -4,9 +4,9 @@ import (
"fmt" "fmt"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template/interpolate"
) )
type StepTagEBSVolumes struct { type StepTagEBSVolumes struct {
@ -44,6 +44,8 @@ func (s *StepTagEBSVolumes) Run(state multistep.StateBag) multistep.StepAction {
return multistep.ActionHalt return multistep.ActionHalt
} }
ReportTags(ui, tags)
_, err = ec2conn.CreateTags(&ec2.CreateTagsInput{ _, err = ec2conn.CreateTags(&ec2.CreateTagsInput{
Resources: volumeIds, Resources: volumeIds,
Tags: tags, Tags: tags,

View File

@ -11,13 +11,13 @@ import (
"github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/helper/config"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
awscommon "github.com/mitchellh/packer/builder/amazon/common"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/helper/communicator"
"github.com/mitchellh/packer/helper/config"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template/interpolate"
) )
// The unique ID for this builder // The unique ID for this builder
@ -58,6 +58,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
return nil, err return nil, err
} }
if b.config.PackerConfig.PackerForce {
b.config.AMIForceDeregister = true
}
// Accumulate any errors // Accumulate any errors
var errs *packer.MultiError var errs *packer.MultiError
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)

View File

@ -8,9 +8,9 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/mitchellh/packer/builder/amazon/common" "github.com/hashicorp/packer/builder/amazon/common"
builderT "github.com/mitchellh/packer/helper/builder/testing" builderT "github.com/hashicorp/packer/helper/builder/testing"
"github.com/mitchellh/packer/packer" "github.com/hashicorp/packer/packer"
) )
func TestBuilderAcc_basic(t *testing.T) { func TestBuilderAcc_basic(t *testing.T) {

View File

@ -3,7 +3,7 @@ package ebs
import ( import (
"testing" "testing"
"github.com/mitchellh/packer/packer" "github.com/hashicorp/packer/packer"
) )
func testConfig() map[string]interface{} { func testConfig() map[string]interface{} {

View File

@ -5,9 +5,9 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/builder/amazon/common"
"github.com/mitchellh/packer/packer"
) )
// stepCleanupVolumes cleans up any orphaned volumes that were not designated to // stepCleanupVolumes cleans up any orphaned volumes that were not designated to

View File

@ -4,9 +4,9 @@ import (
"fmt" "fmt"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
awscommon "github.com/mitchellh/packer/builder/amazon/common"
"github.com/mitchellh/packer/packer"
) )
type stepCreateAMI struct { type stepCreateAMI struct {

View File

@ -7,9 +7,9 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/mitchellh/packer/builder/amazon/common" "github.com/hashicorp/packer/builder/amazon/common"
builderT "github.com/mitchellh/packer/helper/builder/testing" builderT "github.com/hashicorp/packer/helper/builder/testing"
"github.com/mitchellh/packer/packer" "github.com/hashicorp/packer/packer"
) )
type TFBuilder struct { type TFBuilder struct {
@ -84,11 +84,11 @@ func checkTags() builderT.TestCheckFunc {
}) })
if err != nil { if err != nil {
return fmt.Errorf("Error retreiving Snapshots for AMI Artifcat (%#v) in Tags Test: %s", artifact, err) return fmt.Errorf("Error retrieving Snapshots for AMI Artifact (%#v) in Tags Test: %s", artifact, err)
} }
if len(resp.Snapshots) == 0 { if len(resp.Snapshots) == 0 {
return fmt.Errorf("No Snapshots found for AMI Artifcat (%#v) in Tags Test", artifact) return fmt.Errorf("No Snapshots found for AMI Artifact (%#v) in Tags Test", artifact)
} }
// Grab the snapshots, check the tags // Grab the snapshots, check the tags

View File

@ -10,13 +10,13 @@ import (
"github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/errwrap" "github.com/hashicorp/errwrap"
awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/helper/config"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
awscommon "github.com/mitchellh/packer/builder/amazon/common"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/helper/communicator"
"github.com/mitchellh/packer/helper/config"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template/interpolate"
) )
const BuilderId = "mitchellh.amazon.ebssurrogate" const BuilderId = "mitchellh.amazon.ebssurrogate"
@ -58,6 +58,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
return nil, err return nil, err
} }
if b.config.PackerConfig.PackerForce {
b.config.AMIForceDeregister = true
}
// Accumulate any errors // Accumulate any errors
var errs *packer.MultiError var errs *packer.MultiError
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)

View File

@ -3,7 +3,7 @@ package ebssurrogate
import ( import (
"testing" "testing"
"github.com/mitchellh/packer/packer" "github.com/hashicorp/packer/packer"
) )
func testConfig() map[string]interface{} { func testConfig() map[string]interface{} {

View File

@ -4,7 +4,7 @@ import (
"errors" "errors"
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/mitchellh/packer/template/interpolate" "github.com/hashicorp/packer/template/interpolate"
) )
type RootBlockDevice struct { type RootBlockDevice struct {

View File

@ -5,9 +5,9 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
awscommon "github.com/mitchellh/packer/builder/amazon/common"
"github.com/mitchellh/packer/packer"
) )
// StepRegisterAMI creates the AMI. // StepRegisterAMI creates the AMI.

View File

@ -6,9 +6,9 @@ import (
"time" "time"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
awscommon "github.com/mitchellh/packer/builder/amazon/common"
"github.com/mitchellh/packer/packer"
) )
// StepSnapshotNewRootVolume creates a snapshot of the created volume. // StepSnapshotNewRootVolume creates a snapshot of the created volume.

View File

@ -7,7 +7,7 @@ import (
"strings" "strings"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/mitchellh/packer/packer" "github.com/hashicorp/packer/packer"
) )
// map of region to list of volume IDs // map of region to list of volume IDs

View File

@ -1,8 +1,8 @@
package ebsvolume package ebsvolume
import ( import (
awscommon "github.com/mitchellh/packer/builder/amazon/common" awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/mitchellh/packer/template/interpolate" "github.com/hashicorp/packer/template/interpolate"
) )
type BlockDevice struct { type BlockDevice struct {

View File

@ -9,13 +9,13 @@ import (
"github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/errwrap" "github.com/hashicorp/errwrap"
awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/helper/config"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
awscommon "github.com/mitchellh/packer/builder/amazon/common"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/helper/communicator"
"github.com/mitchellh/packer/helper/config"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template/interpolate"
) )
const BuilderId = "mitchellh.amazon.ebsvolume" const BuilderId = "mitchellh.amazon.ebsvolume"

View File

@ -3,7 +3,7 @@ package ebsvolume
import ( import (
"testing" "testing"
"github.com/mitchellh/packer/packer" "github.com/hashicorp/packer/packer"
) )
func testConfig() map[string]interface{} { func testConfig() map[string]interface{} {

View File

@ -4,10 +4,10 @@ import (
"fmt" "fmt"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
awscommon "github.com/mitchellh/packer/builder/amazon/common"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template/interpolate"
) )
type stepTagEBSVolumes struct { type stepTagEBSVolumes struct {
@ -50,6 +50,7 @@ func (s *stepTagEBSVolumes) Run(state multistep.StateBag) multistep.StepAction {
ui.Error(err.Error()) ui.Error(err.Error())
return multistep.ActionHalt return multistep.ActionHalt
} }
awscommon.ReportTags(ui, tags)
for _, v := range instance.BlockDeviceMappings { for _, v := range instance.BlockDeviceMappings {
if *v.DeviceName == mapping.DeviceName { if *v.DeviceName == mapping.DeviceName {

View File

@ -11,13 +11,13 @@ import (
"github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/helper/config"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
awscommon "github.com/mitchellh/packer/builder/amazon/common"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/helper/communicator"
"github.com/mitchellh/packer/helper/config"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template/interpolate"
) )
// The unique ID for this builder // The unique ID for this builder
@ -77,6 +77,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
return nil, err return nil, err
} }
if b.config.PackerConfig.PackerForce {
b.config.AMIForceDeregister = true
}
if b.config.BundleDestination == "" { if b.config.BundleDestination == "" {
b.config.BundleDestination = "/tmp" b.config.BundleDestination = "/tmp"
} }

View File

@ -1,7 +1,7 @@
package instance package instance
import ( import (
"github.com/mitchellh/packer/packer" "github.com/hashicorp/packer/packer"
"io/ioutil" "io/ioutil"
"os" "os"
"testing" "testing"

View File

@ -4,9 +4,9 @@ import (
"fmt" "fmt"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template/interpolate"
) )
type bundleCmdData struct { type bundleCmdData struct {

View File

@ -5,9 +5,9 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
awscommon "github.com/mitchellh/packer/builder/amazon/common"
"github.com/mitchellh/packer/packer"
) )
type StepRegisterAMI struct{} type StepRegisterAMI struct{}

View File

@ -3,9 +3,9 @@ package instance
import ( import (
"fmt" "fmt"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template/interpolate"
) )
type uploadCmdData struct { type uploadCmdData struct {

Some files were not shown because too many files have changed in this diff Show More