Merge remote-tracking branch 'origin/master' into up-aws-sdk-go
This commit is contained in:
commit
2b63569ce9
|
@ -129,8 +129,13 @@ to use `git push ...`.
|
|||
we want to understand your thought process.
|
||||
|
||||
4. If we have requested changes, you can either make those changes or, if you
|
||||
disagree with the suggested changes, we can have a conversation about our reasoning and agree on a path forward. This may be a multi-step process. Our view is that pull requests are a chance to collaborate, and we welcome
|
||||
conversations about how to do things better.
|
||||
disagree with the suggested changes, we can have a conversation about our
|
||||
reasoning and agree on a path forward. This may be a multi-step process. Our
|
||||
view is that pull requests are a chance to collaborate, and we welcome
|
||||
conversations about how to do things better. It is the contributor's
|
||||
responsibility to address any changes requested. While reviewers are happy to
|
||||
give guidance, it is unsustainable for us to perform the coding work necessary
|
||||
to get a PR into a mergeable state.
|
||||
|
||||
5. Once all outstanding comments and checklist items have been addressed, your
|
||||
contribution will be merged! Merged PRs will be included in the next
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
**DELETE THIS TEMPLATE BEFORE SUBMITTING**
|
||||
|
||||
In order to have a good experience with our community, we recommend that you
|
||||
read the contributing guidelines for making a PR, and understand the lifecycle
|
||||
of a Packer PR:
|
||||
|
||||
https://github.com/hashicorp/packer/blob/master/.github/CONTRIBUTING.md#opening-an-pull-request
|
||||
|
||||
Describe the change you are making here!
|
||||
|
||||
Please include tests. Check out these examples:
|
||||
|
|
39
CHANGELOG.md
39
CHANGELOG.md
|
@ -8,24 +8,61 @@
|
|||
per builder [GH-7080]
|
||||
* builder/amazon: don't Cleanup Temp Keys when there is no communicator to
|
||||
avoid a panic [GH-7100] [GH-7095]
|
||||
* builder/azure: allow to configure disk caching [GH-7061]
|
||||
* builder/amazon: Import error messages should now contain reason for failure
|
||||
[GH-7207]
|
||||
* builder/azure: add certificate authentication [GH-7189]
|
||||
* builder/azure: allow to configure disk caching [GH-7061]
|
||||
* builder/azure: use deallocate instead of just power-off [GH-7203]
|
||||
* builder/hyperv: Add support for legacy network adapters on Hyper-V. [GH-7128]
|
||||
* builder/hyperv: Allow user to set `version` option in the New-VM command.
|
||||
[GH-7136]
|
||||
* builder/openstack: Add `volume_size` option [GH-7130]
|
||||
* builder/openstack: Don't require network v2 [GH-6933]
|
||||
* builder/openstack: Support for tagging new images [GH-7037]
|
||||
* builder/qemu: Add support for whpx accelerator to qemu builder [GH-7151]
|
||||
* core/shell: Add env vars "PACKER_HTTP_IP" and "PACKER_HTTP_PORT" to shell
|
||||
provisioners [GH-7075]
|
||||
* core: Clean up internal handling and creation of temporary directories
|
||||
[GH-7102]
|
||||
* core: Deprecate mitchellh/go-homedir package in favor of os/user [GH-7062]
|
||||
* core: Download checksum match failures will now log the received checksum.
|
||||
[GH-7210]
|
||||
* core: make packer inspect not print sensitive variables [GH-7084]
|
||||
* post-processor/google: Add new `guest-os-features` option. [GH-7218]
|
||||
* postprocessor/docker-import: Added `change` support [GH-7127]
|
||||
* provisioner/ansible-remote: add `-o IdentitiesOnly=yes`as a default flag
|
||||
[GH-7115]
|
||||
* provisioner/chef-client: Elevated support for chef-client provisioner
|
||||
[GH-7078]
|
||||
* provisioner/puppet: Elevated support for puppet-* provisioner [GH-7078]
|
||||
* provisioner/windows-restart: wait for already-scheduled reboot [GH-7056] and
|
||||
ignore reboot specific errors [GH-7071]
|
||||
|
||||
|
||||
### BUG FIXES:
|
||||
* builder/azure: Ensure the Windows Guest Agent is fully functional before
|
||||
Sysprep is executed. [GH-7176]
|
||||
* builder/azure: Fix snapshot regression [GH-7111]
|
||||
* builder/docker: Ensure that entrypoint and arguments get passed to docker,
|
||||
not the image. [GH-7091]
|
||||
* builder/hcloud: fix go mod dependency [GH-7099]
|
||||
* builder/hcloud: prevent panic when ssh key was not passed [GH-7118]
|
||||
* builder/hyperv: Fix the Hyper-V gen 1 guest boot order. [GH-7147]
|
||||
* builder/hyperv: hyper-v builder no longer ignores `ssh_host` option.
|
||||
[GH-7154]
|
||||
* builder/oracle-oci: Fix crash that occurs when image is nil [GH-7126]
|
||||
* builder/parallels: Fix attaching prl tools [GH-7158]
|
||||
* builder/virtualbox: Fix handling of portcount argument for version 6 beta
|
||||
[GH-7174] [GH-7094]
|
||||
* builder/vmware: Fix bug caused by 'nil' dir field in artifact struct when
|
||||
building locally [GH-7116]
|
||||
* communicator/docker: Fix docker file provisioner on Windows [GH-7163]
|
||||
* core: prioritize AppData over default user directory ( UserProfile )
|
||||
[GH-7166]
|
||||
* core: removed a flaky race condition in tests [GH-7119]
|
||||
* postprocessor/vsphere: Stop setting HDDOrder, since it was breaking uploads
|
||||
[GH-7108]
|
||||
|
||||
|
||||
## 1.3.3 (December 5, 2018)
|
||||
### IMPROVEMENTS:
|
||||
|
|
|
@ -54,11 +54,7 @@ func (c *AccessConfig) Session() (*session.Session, error) {
|
|||
// retries are exponentially backed off.
|
||||
config = config.WithMaxRetries(8)
|
||||
|
||||
region, err := c.region()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Could not get region, "+
|
||||
"probably because it's not set or we're not running on AWS. %s", err)
|
||||
}
|
||||
region, _ := c.region()
|
||||
config = config.WithRegion(region)
|
||||
|
||||
if c.CustomEndpointEc2 != "" {
|
||||
|
|
|
@ -34,6 +34,9 @@ func (c *AccessConfig) ValidateRegion(regions ...string) error {
|
|||
|
||||
var invalidRegions []string
|
||||
for _, region := range regions {
|
||||
if region == "" {
|
||||
continue
|
||||
}
|
||||
found := false
|
||||
for _, validRegion := range validRegions {
|
||||
if region == validRegion {
|
||||
|
|
|
@ -4,10 +4,10 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/hashicorp/packer/packer/tmp"
|
||||
)
|
||||
|
||||
// StepTempDir creates a temporary directory that we use in order to
|
||||
|
@ -16,12 +16,33 @@ type StepTempDir struct {
|
|||
tempDir string
|
||||
}
|
||||
|
||||
// ConfigTmpDir returns the configuration tmp directory for Docker
|
||||
func ConfigTmpDir() (string, error) {
|
||||
if tmpdir := os.Getenv("PACKER_TMP_DIR"); tmpdir != "" {
|
||||
return filepath.Abs(tmpdir)
|
||||
}
|
||||
configdir, err := packer.ConfigDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
td := filepath.Join(configdir, "tmp")
|
||||
_, err = os.Stat(td)
|
||||
if os.IsNotExist(err) {
|
||||
if err = os.MkdirAll(td, 0755); err != nil {
|
||||
return "", err
|
||||
}
|
||||
} else if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return td, nil
|
||||
}
|
||||
|
||||
func (s *StepTempDir) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
|
||||
ui.Say("Creating a temporary directory for sharing data...")
|
||||
|
||||
tempdir, err := tmp.Dir("packer-docker")
|
||||
tempdir, err := ConfigTmpDir()
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Error making temp dir: %s", err)
|
||||
state.Put("error", err)
|
||||
|
|
|
@ -97,6 +97,7 @@ type Config struct {
|
|||
|
||||
ISOSkipCache bool `mapstructure:"iso_skip_cache"`
|
||||
Accelerator string `mapstructure:"accelerator"`
|
||||
CpuCount int `mapstructure:"cpus"`
|
||||
DiskInterface string `mapstructure:"disk_interface"`
|
||||
DiskSize uint `mapstructure:"disk_size"`
|
||||
DiskCache string `mapstructure:"disk_cache"`
|
||||
|
@ -109,6 +110,7 @@ type Config struct {
|
|||
DiskImage bool `mapstructure:"disk_image"`
|
||||
UseBackingFile bool `mapstructure:"use_backing_file"`
|
||||
MachineType string `mapstructure:"machine_type"`
|
||||
MemorySize int `mapstructure:"memory"`
|
||||
NetDevice string `mapstructure:"net_device"`
|
||||
OutputDir string `mapstructure:"output_directory"`
|
||||
QemuArgs [][]string `mapstructure:"qemuargs"`
|
||||
|
@ -201,6 +203,16 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
|
|||
b.config.QemuBinary = "qemu-system-x86_64"
|
||||
}
|
||||
|
||||
if b.config.MemorySize < 10 {
|
||||
log.Printf("MemorySize %d is too small, using default: 512", b.config.MemorySize)
|
||||
b.config.MemorySize = 512
|
||||
}
|
||||
|
||||
if b.config.CpuCount < 1 {
|
||||
log.Printf("CpuCount %d too small, using default: 1", b.config.CpuCount)
|
||||
b.config.CpuCount = 1
|
||||
}
|
||||
|
||||
if b.config.SSHHostPortMin == 0 {
|
||||
b.config.SSHHostPortMin = 2222
|
||||
}
|
||||
|
|
|
@ -150,7 +150,10 @@ func getCommandArgs(bootDrive string, state multistep.StateBag) ([]string, error
|
|||
defaultArgs["-cdrom"] = isoPath
|
||||
}
|
||||
defaultArgs["-boot"] = bootDrive
|
||||
defaultArgs["-m"] = "512M"
|
||||
defaultArgs["-m"] = fmt.Sprintf("%dM", config.MemorySize)
|
||||
if config.CpuCount > 1 {
|
||||
defaultArgs["-smp"] = fmt.Sprintf("cpus=%d,sockets=%d", config.CpuCount, config.CpuCount)
|
||||
}
|
||||
defaultArgs["-vnc"] = vnc
|
||||
|
||||
// Append the accelerator to the machine type if it is specified
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
"github.com/hashicorp/packer/builder/file"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
shell_local "github.com/hashicorp/packer/post-processor/shell-local"
|
||||
)
|
||||
|
||||
func TestBuildOnlyFileCommaFlags(t *testing.T) {
|
||||
|
@ -26,12 +27,13 @@ func TestBuildOnlyFileCommaFlags(t *testing.T) {
|
|||
fatalCommand(t, c.Meta)
|
||||
}
|
||||
|
||||
if !fileExists("chocolate.txt") {
|
||||
t.Error("Expected to find chocolate.txt")
|
||||
}
|
||||
if !fileExists("vanilla.txt") {
|
||||
t.Error("Expected to find vanilla.txt")
|
||||
for _, f := range []string{"chocolate.txt", "vanilla.txt",
|
||||
"apple.txt", "peach.txt", "pear.txt"} {
|
||||
if !fileExists(f) {
|
||||
t.Errorf("Expected to find %s", f)
|
||||
}
|
||||
}
|
||||
|
||||
if fileExists("cherry.txt") {
|
||||
t.Error("Expected NOT to find cherry.txt")
|
||||
}
|
||||
|
@ -56,14 +58,10 @@ func TestBuildStdin(t *testing.T) {
|
|||
fatalCommand(t, c.Meta)
|
||||
}
|
||||
|
||||
if !fileExists("chocolate.txt") {
|
||||
t.Error("Expected to find chocolate.txt")
|
||||
}
|
||||
if !fileExists("vanilla.txt") {
|
||||
t.Error("Expected to find vanilla.txt")
|
||||
}
|
||||
if !fileExists("cherry.txt") {
|
||||
t.Error("Expected to find cherry.txt")
|
||||
for _, f := range []string{"vanilla.txt", "cherry.txt", "chocolate.txt"} {
|
||||
if !fileExists(f) {
|
||||
t.Errorf("Expected to find %s", f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,6 +73,9 @@ func TestBuildOnlyFileMultipleFlags(t *testing.T) {
|
|||
args := []string{
|
||||
"-only=chocolate",
|
||||
"-only=cherry",
|
||||
"-only=apple", // ignored
|
||||
"-only=peach", // ignored
|
||||
"-only=pear", // ignored
|
||||
filepath.Join(testFixture("build-only"), "template.json"),
|
||||
}
|
||||
|
||||
|
@ -84,14 +85,16 @@ func TestBuildOnlyFileMultipleFlags(t *testing.T) {
|
|||
fatalCommand(t, c.Meta)
|
||||
}
|
||||
|
||||
if !fileExists("chocolate.txt") {
|
||||
t.Error("Expected to find chocolate.txt")
|
||||
for _, f := range []string{"vanilla.txt"} {
|
||||
if fileExists(f) {
|
||||
t.Errorf("Expected NOT to find %s", f)
|
||||
}
|
||||
}
|
||||
if fileExists("vanilla.txt") {
|
||||
t.Error("Expected NOT to find vanilla.txt")
|
||||
}
|
||||
if !fileExists("cherry.txt") {
|
||||
t.Error("Expected to find cherry.txt")
|
||||
for _, f := range []string{"chocolate.txt", "cherry.txt",
|
||||
"apple.txt", "peach.txt", "pear.txt"} {
|
||||
if !fileExists(f) {
|
||||
t.Errorf("Expected to find %s", f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +104,7 @@ func TestBuildExceptFileCommaFlags(t *testing.T) {
|
|||
}
|
||||
|
||||
args := []string{
|
||||
"-except=chocolate",
|
||||
"-except=chocolate,apple",
|
||||
filepath.Join(testFixture("build-only"), "template.json"),
|
||||
}
|
||||
|
||||
|
@ -111,14 +114,15 @@ func TestBuildExceptFileCommaFlags(t *testing.T) {
|
|||
fatalCommand(t, c.Meta)
|
||||
}
|
||||
|
||||
if fileExists("chocolate.txt") {
|
||||
t.Error("Expected NOT to find chocolate.txt")
|
||||
for _, f := range []string{"chocolate.txt", "apple.txt", "peach.txt"} {
|
||||
if fileExists(f) {
|
||||
t.Errorf("Expected NOT to find %s", f)
|
||||
}
|
||||
}
|
||||
if !fileExists("vanilla.txt") {
|
||||
t.Error("Expected to find vanilla.txt")
|
||||
}
|
||||
if !fileExists("cherry.txt") {
|
||||
t.Error("Expected to find cherry.txt")
|
||||
for _, f := range []string{"vanilla.txt", "cherry.txt", "pear.txt"} {
|
||||
if !fileExists(f) {
|
||||
t.Errorf("Expected to find %s", f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,6 +141,9 @@ func testCoreConfigBuilder(t *testing.T) *packer.CoreConfig {
|
|||
Builder: func(n string) (packer.Builder, error) {
|
||||
return &file.Builder{}, nil
|
||||
},
|
||||
PostProcessor: func(n string) (packer.PostProcessor, error) {
|
||||
return &shell_local.PostProcessor{}, nil
|
||||
},
|
||||
}
|
||||
return &packer.CoreConfig{
|
||||
Components: components,
|
||||
|
@ -159,4 +166,7 @@ func cleanup() {
|
|||
os.RemoveAll("chocolate.txt")
|
||||
os.RemoveAll("vanilla.txt")
|
||||
os.RemoveAll("cherry.txt")
|
||||
os.RemoveAll("apple.txt")
|
||||
os.RemoveAll("peach.txt")
|
||||
os.RemoveAll("pear.txt")
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/hashicorp/packer/helper/flag-kv"
|
||||
"github.com/hashicorp/packer/helper/flag-slice"
|
||||
kvflag "github.com/hashicorp/packer/helper/flag-kv"
|
||||
sliceflag "github.com/hashicorp/packer/helper/flag-slice"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/hashicorp/packer/template"
|
||||
)
|
||||
|
@ -31,9 +31,7 @@ type Meta struct {
|
|||
Version string
|
||||
|
||||
// These are set by command-line flags
|
||||
flagBuildExcept []string
|
||||
flagBuildOnly []string
|
||||
flagVars map[string]string
|
||||
flagVars map[string]string
|
||||
}
|
||||
|
||||
// Core returns the core for the given template given the configured
|
||||
|
@ -59,7 +57,7 @@ func (m *Meta) BuildNames(c *packer.Core) []string {
|
|||
// TODO: test
|
||||
|
||||
// Filter the "only"
|
||||
if len(m.flagBuildOnly) > 0 {
|
||||
if len(m.CoreConfig.Only) > 0 {
|
||||
// Build a set of all the available names
|
||||
nameSet := make(map[string]struct{})
|
||||
for _, n := range c.BuildNames() {
|
||||
|
@ -67,8 +65,8 @@ func (m *Meta) BuildNames(c *packer.Core) []string {
|
|||
}
|
||||
|
||||
// Build our result set which we pre-allocate some sane number
|
||||
result := make([]string, 0, len(m.flagBuildOnly))
|
||||
for _, n := range m.flagBuildOnly {
|
||||
result := make([]string, 0, len(m.CoreConfig.Only))
|
||||
for _, n := range m.CoreConfig.Only {
|
||||
if _, ok := nameSet[n]; ok {
|
||||
result = append(result, n)
|
||||
}
|
||||
|
@ -78,10 +76,10 @@ func (m *Meta) BuildNames(c *packer.Core) []string {
|
|||
}
|
||||
|
||||
// Filter the "except"
|
||||
if len(m.flagBuildExcept) > 0 {
|
||||
if len(m.CoreConfig.Except) > 0 {
|
||||
// Build a set of the things we don't want
|
||||
nameSet := make(map[string]struct{})
|
||||
for _, n := range m.flagBuildExcept {
|
||||
for _, n := range m.CoreConfig.Except {
|
||||
nameSet[n] = struct{}{}
|
||||
}
|
||||
|
||||
|
@ -111,8 +109,8 @@ func (m *Meta) FlagSet(n string, fs FlagSetFlags) *flag.FlagSet {
|
|||
// FlagSetBuildFilter tells us to enable the settings for selecting
|
||||
// builds we care about.
|
||||
if fs&FlagSetBuildFilter != 0 {
|
||||
f.Var((*sliceflag.StringFlag)(&m.flagBuildExcept), "except", "")
|
||||
f.Var((*sliceflag.StringFlag)(&m.flagBuildOnly), "only", "")
|
||||
f.Var((*sliceflag.StringFlag)(&m.CoreConfig.Except), "except", "")
|
||||
f.Var((*sliceflag.StringFlag)(&m.CoreConfig.Only), "only", "")
|
||||
}
|
||||
|
||||
// FlagSetVars tells us what variables to use
|
||||
|
|
|
@ -1,22 +1,43 @@
|
|||
{
|
||||
"builders": [
|
||||
{
|
||||
"name":"chocolate",
|
||||
"type":"file",
|
||||
"content":"chocolate",
|
||||
"target":"chocolate.txt"
|
||||
"name": "chocolate",
|
||||
"type": "file",
|
||||
"content": "chocolate",
|
||||
"target": "chocolate.txt"
|
||||
},
|
||||
{
|
||||
"name":"vanilla",
|
||||
"type":"file",
|
||||
"content":"vanilla",
|
||||
"target":"vanilla.txt"
|
||||
"name": "vanilla",
|
||||
"type": "file",
|
||||
"content": "vanilla",
|
||||
"target": "vanilla.txt"
|
||||
},
|
||||
{
|
||||
"name":"cherry",
|
||||
"type":"file",
|
||||
"content":"cherry",
|
||||
"target":"cherry.txt"
|
||||
"name": "cherry",
|
||||
"type": "file",
|
||||
"content": "cherry",
|
||||
"target": "cherry.txt"
|
||||
}
|
||||
],
|
||||
"post-processors": [
|
||||
[
|
||||
{
|
||||
"name": "apple",
|
||||
"type": "shell-local",
|
||||
"inline": [ "touch apple.txt" ]
|
||||
},
|
||||
{
|
||||
"name": "peach",
|
||||
"type": "shell-local",
|
||||
"inline": [ "touch peach.txt" ]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"name": "pear",
|
||||
"type": "shell-local",
|
||||
"inline": [ "touch pear.txt" ]
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ _packer () {
|
|||
'-force[Force a build to continue if artifacts exist, deletes existing artifacts.]'
|
||||
'-machine-readable[Produce machine-readable output.]'
|
||||
'-color=[(false) Disable color output. (Default: color)]'
|
||||
'-except=[(foo,bar,baz) Build all builds other than these.]'
|
||||
'-except=[(foo,bar,baz) Run all builds and post-procesors other than these.]'
|
||||
'-on-error=[(cleanup,abort,ask) If the build fails do: clean up (default), abort, or ask.]'
|
||||
'-only=[(foo,bar,baz) Only build the given builds by name.]'
|
||||
'-parallel=[(false) Disable parallelization. (Default: parallel)]'
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/hashicorp/go-version"
|
||||
multierror "github.com/hashicorp/go-multierror"
|
||||
version "github.com/hashicorp/go-version"
|
||||
"github.com/hashicorp/packer/template"
|
||||
"github.com/hashicorp/packer/template/interpolate"
|
||||
)
|
||||
|
@ -20,6 +20,9 @@ type Core struct {
|
|||
builds map[string]*template.Builder
|
||||
version string
|
||||
secrets []string
|
||||
|
||||
except []string
|
||||
only []string
|
||||
}
|
||||
|
||||
// CoreConfig is the structure for initializing a new Core. Once a CoreConfig
|
||||
|
@ -30,6 +33,10 @@ type CoreConfig struct {
|
|||
Variables map[string]string
|
||||
SensitiveVariables []string
|
||||
Version string
|
||||
|
||||
// These are set by command-line flags
|
||||
Except []string
|
||||
Only []string
|
||||
}
|
||||
|
||||
// The function type used to lookup Builder implementations.
|
||||
|
@ -61,6 +68,8 @@ func NewCore(c *CoreConfig) (*Core, error) {
|
|||
components: c.Components,
|
||||
variables: c.Variables,
|
||||
version: c.Version,
|
||||
only: c.Only,
|
||||
except: c.Except,
|
||||
}
|
||||
|
||||
if err := result.validate(); err != nil {
|
||||
|
@ -126,7 +135,7 @@ func (c *Core) Build(n string) (Build, error) {
|
|||
provisioners := make([]coreBuildProvisioner, 0, len(c.Template.Provisioners))
|
||||
for _, rawP := range c.Template.Provisioners {
|
||||
// If we're skipping this, then ignore it
|
||||
if rawP.Skip(rawName) {
|
||||
if rawP.OnlyExcept.Skip(rawName) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -172,9 +181,13 @@ func (c *Core) Build(n string) (Build, error) {
|
|||
current := make([]coreBuildPostProcessor, 0, len(rawPs))
|
||||
for _, rawP := range rawPs {
|
||||
// If we skip, ignore
|
||||
if rawP.Skip(rawName) {
|
||||
rawP.OnlyExcept.Except = append(rawP.OnlyExcept.Except, c.except...)
|
||||
if rawP.OnlyExcept.Skip(rawName) {
|
||||
continue
|
||||
}
|
||||
if rawP.OnlyExcept.Skip(rawP.Name) {
|
||||
break
|
||||
}
|
||||
|
||||
// Get the post-processor
|
||||
postProcessor, err := c.components.PostProcessor(rawP.Type)
|
||||
|
|
|
@ -25,16 +25,18 @@ import (
|
|||
type Config struct {
|
||||
common.PackerConfig `mapstructure:",squash"`
|
||||
|
||||
Bucket string `mapstructure:"bucket"`
|
||||
GCSObjectName string `mapstructure:"gcs_object_name"`
|
||||
ImageDescription string `mapstructure:"image_description"`
|
||||
ImageFamily string `mapstructure:"image_family"`
|
||||
ImageLabels map[string]string `mapstructure:"image_labels"`
|
||||
ImageName string `mapstructure:"image_name"`
|
||||
ProjectId string `mapstructure:"project_id"`
|
||||
AccountFile string `mapstructure:"account_file"`
|
||||
KeepOriginalImage bool `mapstructure:"keep_input_artifact"`
|
||||
SkipClean bool `mapstructure:"skip_clean"`
|
||||
AccountFile string `mapstructure:"account_file"`
|
||||
ProjectId string `mapstructure:"project_id"`
|
||||
|
||||
Bucket string `mapstructure:"bucket"`
|
||||
GCSObjectName string `mapstructure:"gcs_object_name"`
|
||||
ImageDescription string `mapstructure:"image_description"`
|
||||
ImageFamily string `mapstructure:"image_family"`
|
||||
ImageGuestOsFeatures []string `mapstructure:"image_guest_os_features"`
|
||||
ImageLabels map[string]string `mapstructure:"image_labels"`
|
||||
ImageName string `mapstructure:"image_name"`
|
||||
KeepOriginalImage bool `mapstructure:"keep_input_artifact"`
|
||||
SkipClean bool `mapstructure:"skip_clean"`
|
||||
|
||||
ctx interpolate.Context
|
||||
}
|
||||
|
@ -111,7 +113,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
|
|||
return nil, p.config.KeepOriginalImage, err
|
||||
}
|
||||
|
||||
gceImageArtifact, err := CreateGceImage(p.config.AccountFile, ui, p.config.ProjectId, rawImageGcsPath, p.config.ImageName, p.config.ImageDescription, p.config.ImageFamily, p.config.ImageLabels)
|
||||
gceImageArtifact, err := CreateGceImage(p.config.AccountFile, ui, p.config.ProjectId, rawImageGcsPath, p.config.ImageName, p.config.ImageDescription, p.config.ImageFamily, p.config.ImageLabels, p.config.ImageGuestOsFeatures)
|
||||
if err != nil {
|
||||
return nil, p.config.KeepOriginalImage, err
|
||||
}
|
||||
|
@ -179,7 +181,7 @@ func UploadToBucket(accountFile string, ui packer.Ui, artifact packer.Artifact,
|
|||
return "https://storage.googleapis.com/" + bucket + "/" + gcsObjectName, nil
|
||||
}
|
||||
|
||||
func CreateGceImage(accountFile string, ui packer.Ui, project string, rawImageURL string, imageName string, imageDescription string, imageFamily string, imageLabels map[string]string) (packer.Artifact, error) {
|
||||
func CreateGceImage(accountFile string, ui packer.Ui, project string, rawImageURL string, imageName string, imageDescription string, imageFamily string, imageLabels map[string]string, imageGuestOsFeatures []string) (packer.Artifact, error) {
|
||||
var client *http.Client
|
||||
var account googlecompute.AccountFile
|
||||
|
||||
|
@ -203,13 +205,22 @@ func CreateGceImage(accountFile string, ui packer.Ui, project string, rawImageUR
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Build up the imageFeatures
|
||||
imageFeatures := make([]*compute.GuestOsFeature, len(imageGuestOsFeatures))
|
||||
for _, v := range imageGuestOsFeatures {
|
||||
imageFeatures = append(imageFeatures, &compute.GuestOsFeature{
|
||||
Type: v,
|
||||
})
|
||||
}
|
||||
|
||||
gceImage := &compute.Image{
|
||||
Name: imageName,
|
||||
Description: imageDescription,
|
||||
Family: imageFamily,
|
||||
Labels: imageLabels,
|
||||
RawDisk: &compute.ImageRawDisk{Source: rawImageURL},
|
||||
SourceType: "RAW",
|
||||
Description: imageDescription,
|
||||
Family: imageFamily,
|
||||
GuestOsFeatures: imageFeatures,
|
||||
Labels: imageLabels,
|
||||
Name: imageName,
|
||||
RawDisk: &compute.ImageRawDisk{Source: rawImageURL},
|
||||
SourceType: "RAW",
|
||||
}
|
||||
|
||||
ui.Say(fmt.Sprintf("Creating GCE image %v...", imageName))
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/go-multierror"
|
||||
multierror "github.com/hashicorp/go-multierror"
|
||||
"github.com/hashicorp/packer/packer/tmp"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
)
|
||||
|
@ -149,6 +149,7 @@ func (r *rawTemplate) Template() (*Template, error) {
|
|||
delete(c, "only")
|
||||
delete(c, "keep_input_artifact")
|
||||
delete(c, "type")
|
||||
delete(c, "name")
|
||||
if len(c) > 0 {
|
||||
pp.Config = c
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/go-multierror"
|
||||
multierror "github.com/hashicorp/go-multierror"
|
||||
)
|
||||
|
||||
// Template represents the parsed template that is used to configure
|
||||
|
@ -40,6 +40,7 @@ type Builder struct {
|
|||
type PostProcessor struct {
|
||||
OnlyExcept `mapstructure:",squash"`
|
||||
|
||||
Name string
|
||||
Type string
|
||||
KeepInputArtifact bool `mapstructure:"keep_input_artifact"`
|
||||
Config map[string]interface{}
|
||||
|
|
|
@ -104,7 +104,7 @@ GEM
|
|||
mini_portile2 (2.3.0)
|
||||
minitest (5.11.3)
|
||||
multi_json (1.13.1)
|
||||
nokogiri (1.8.2)
|
||||
nokogiri (1.8.5)
|
||||
mini_portile2 (~> 2.3.0)
|
||||
padrino-helpers (0.12.9)
|
||||
i18n (~> 0.6, >= 0.6.7)
|
||||
|
|
|
@ -380,9 +380,8 @@ portable provisioning scripts.
|
|||
|
||||
## Overriding the host directory
|
||||
|
||||
By default, Packer creates a temporary folder under your system temporary
|
||||
directory, and uses that to stage files for uploading into the container. If
|
||||
you would like to change the path to this temporary folder, you can set
|
||||
environment variable `TMPDIR` (Unix) / `TMP` `TEMP` `USERPROFILE` (Windows) .
|
||||
By default, Packer creates a temporary folder under your home directory, and
|
||||
uses that to stage files for uploading into the container. If you would like to
|
||||
change the path to this temporary folder, you can set the `PACKER_TMP_DIR`.
|
||||
This can be useful, for example, if you have your home directory permissions
|
||||
set up to disallow access from the docker daemon.
|
||||
|
|
|
@ -94,6 +94,9 @@ builder.
|
|||
Packer to wait for 1 minute 30 seconds before typing the boot command.
|
||||
The default duration is "10s" (10 seconds).
|
||||
|
||||
- `configuration_version` - This allows you to set the vm version when
|
||||
calling New-VM to generate the vm.
|
||||
|
||||
- `cpu` (number) - The number of CPUs the virtual machine should use. If
|
||||
this isn't specified, the default is 1 CPU.
|
||||
|
||||
|
|
|
@ -125,6 +125,9 @@ builder.
|
|||
Where $copy is replaced with either true or false depending on the value of
|
||||
"copy_in_compare".
|
||||
|
||||
- `configuration_version` - This allows you to set the vm version when
|
||||
calling New-VM to generate the vm.
|
||||
|
||||
- `cpu` (number) - The number of CPUs the virtual machine should use. If
|
||||
this isn't specified, the default is 1 CPU.
|
||||
|
||||
|
|
|
@ -139,6 +139,9 @@ Linux server and have not enabled X11 forwarding (`ssh -X`).
|
|||
five seconds and one minute 30 seconds, respectively. If this isn't
|
||||
specified, the default is `10s` or 10 seconds.
|
||||
|
||||
- `cpus` (number) - The number of cpus to use when building the VM.
|
||||
The default is `1` CPU.
|
||||
|
||||
- `disk_cache` (string) - The cache mode to use for disk. Allowed values
|
||||
include any of `writethrough`, `writeback`, `none`, `unsafe`
|
||||
or `directsync`. By default, this is set to `writeback`.
|
||||
|
@ -241,6 +244,9 @@ Linux server and have not enabled X11 forwarding (`ssh -X`).
|
|||
qemu binary with the flags `-machine help` to list available types for
|
||||
your system. This defaults to `pc`.
|
||||
|
||||
- `memory` (number) - The amount of memory to use when building the VM
|
||||
in megabytes. This defaults to `512` megabytes.
|
||||
|
||||
- `net_device` (string) - The driver to use for the network interface. Allowed
|
||||
values `ne2k_pci`, `i82551`, `i82557b`, `i82559er`, `rtl8139`, `e1000`,
|
||||
`pcnet`, `virtio`, `virtio-net`, `virtio-net-pci`, `usb-net`, `i82559a`,
|
||||
|
|
|
@ -26,10 +26,12 @@ artifacts that are created will be outputted at the end of the build.
|
|||
will stop between each step, waiting for keyboard input before continuing.
|
||||
This will allow the user to inspect state and so on.
|
||||
|
||||
- `-except=foo,bar,baz` - Builds all the builds except those with the given
|
||||
comma-separated names. Build names by default are the names of their
|
||||
builders, unless a specific `name` attribute is specified within the
|
||||
configuration.
|
||||
- `-except=foo,bar,baz` - Run all the builds and post-processors except those
|
||||
with the given comma-separated names. Build and post-processor names by
|
||||
default are their type, unless a specific `name` attribute is specified
|
||||
within the configuration. Any post-processor following a skipped
|
||||
post-processor will not run. Because post-processors can be nested in
|
||||
arrays a differ post-processor chain can still run.
|
||||
|
||||
- `-force` - Forces a builder to run when artifacts from a previous build
|
||||
prevent a build from running. The exact behavior of a forced build is left
|
||||
|
@ -44,9 +46,10 @@ artifacts that are created will be outputted at the end of the build.
|
|||
presents a prompt and waits for you to decide to clean up, abort, or retry
|
||||
the failed step.
|
||||
|
||||
- `-only=foo,bar,baz` - Only build the builds with the given comma-separated
|
||||
names. Build names by default are the names of their builders, unless a
|
||||
specific `name` attribute is specified within the configuration.
|
||||
- `-only=foo,bar,baz` - Only run the builds with the given comma-separated
|
||||
names. Build names by default are their type, unless a specific `name`
|
||||
attribute is specified within the configuration. `-only` does not apply to
|
||||
post-processors.
|
||||
|
||||
- `-parallel=false` - Disable parallelization of multiple builders (on by
|
||||
default).
|
||||
|
|
|
@ -61,6 +61,11 @@ for details.
|
|||
- `image_labels` (object of key/value strings) - Key/value pair labels to
|
||||
apply to the created image.
|
||||
|
||||
- `image_guest_os_features` (array of strings) - A list of features to enable
|
||||
on the guest operating system. Applicable only for bootable images. Valid
|
||||
values are `MULTI_IP_SUBNET`, `SECURE_BOOT`, `UEFI_COMPATIBLE`,
|
||||
`VIRTIO_SCSI_MULTIQUEUE` and `WINDOWS` currently.
|
||||
|
||||
- `keep_input_artifact` (boolean) - if true, do not delete the compressed RAW
|
||||
disk image. Defaults to false.
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ The values within `only` or `except` are *build names*, not builder types. If
|
|||
you recall, build names by default are just their builder type, but if you
|
||||
specify a custom `name` parameter, then you should use that as the value
|
||||
instead of the type.
|
||||
Values within `except` could also be a *post-processor* name.
|
||||
|
||||
## Build-Specific Overrides
|
||||
|
||||
|
|
Loading…
Reference in New Issue