Commit 56c3cbfb authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/common: common config struct for Packer configs

parent 4878cec0
...@@ -22,6 +22,7 @@ import ( ...@@ -22,6 +22,7 @@ import (
const BuilderId = "mitchellh.amazonebs" const BuilderId = "mitchellh.amazonebs"
type config struct { type config struct {
common.PackerConfig `mapstructure:",squash"`
awscommon.AccessConfig `mapstructure:",squash"` awscommon.AccessConfig `mapstructure:",squash"`
VpcId string `mapstructure:"vpc_id"` VpcId string `mapstructure:"vpc_id"`
SubnetId string `mapstructure:"subnet_id"` SubnetId string `mapstructure:"subnet_id"`
...@@ -29,8 +30,6 @@ type config struct { ...@@ -29,8 +30,6 @@ type config struct {
// Configuration of the resulting AMI // Configuration of the resulting AMI
AMIName string `mapstructure:"ami_name"` AMIName string `mapstructure:"ami_name"`
PackerDebug bool `mapstructure:"packer_debug"`
} }
type Builder struct { type Builder struct {
......
package common
// PackerConfig is a struct that contains the configuration keys that
// are sent by packer, properly tagged already so mapstructure can load
// them. Embed this structure into your configuration class to get it.
type PackerConfig struct {
PackerBuildName string `mapstructure:"packer_build_name"`
PackerDebug bool `mapstructure:"packer_debug"`
PackerForce bool `mapstructure:"packer_force"`
}
...@@ -28,6 +28,8 @@ type snapshotNameData struct { ...@@ -28,6 +28,8 @@ type snapshotNameData struct {
// to use while communicating with DO and describes the image // to use while communicating with DO and describes the image
// you are creating // you are creating
type config struct { type config struct {
common.PackerConfig `mapstructure:",squash"`
ClientID string `mapstructure:"client_id"` ClientID string `mapstructure:"client_id"`
APIKey string `mapstructure:"api_key"` APIKey string `mapstructure:"api_key"`
RegionID uint `mapstructure:"region_id"` RegionID uint `mapstructure:"region_id"`
...@@ -38,8 +40,6 @@ type config struct { ...@@ -38,8 +40,6 @@ type config struct {
SSHUsername string `mapstructure:"ssh_username"` SSHUsername string `mapstructure:"ssh_username"`
SSHPort uint `mapstructure:"ssh_port"` SSHPort uint `mapstructure:"ssh_port"`
PackerDebug bool `mapstructure:"packer_debug"`
RawSnapshotName string `mapstructure:"snapshot_name"` RawSnapshotName string `mapstructure:"snapshot_name"`
RawSSHTimeout string `mapstructure:"ssh_timeout"` RawSSHTimeout string `mapstructure:"ssh_timeout"`
RawEventDelay string `mapstructure:"event_delay"` RawEventDelay string `mapstructure:"event_delay"`
......
...@@ -24,6 +24,8 @@ type Builder struct { ...@@ -24,6 +24,8 @@ type Builder struct {
} }
type config struct { type config struct {
common.PackerConfig `mapstructure:",squash"`
BootCommand []string `mapstructure:"boot_command"` BootCommand []string `mapstructure:"boot_command"`
DiskSize uint `mapstructure:"disk_size"` DiskSize uint `mapstructure:"disk_size"`
FloppyFiles []string `mapstructure:"floppy_files"` FloppyFiles []string `mapstructure:"floppy_files"`
...@@ -49,10 +51,6 @@ type config struct { ...@@ -49,10 +51,6 @@ type config struct {
VBoxManage [][]string `mapstructure:"vboxmanage"` VBoxManage [][]string `mapstructure:"vboxmanage"`
VMName string `mapstructure:"vm_name"` VMName string `mapstructure:"vm_name"`
PackerBuildName string `mapstructure:"packer_build_name"`
PackerDebug bool `mapstructure:"packer_debug"`
PackerForce bool `mapstructure:"packer_force"`
RawBootWait string `mapstructure:"boot_wait"` RawBootWait string `mapstructure:"boot_wait"`
RawShutdownTimeout string `mapstructure:"shutdown_timeout"` RawShutdownTimeout string `mapstructure:"shutdown_timeout"`
RawSSHWaitTimeout string `mapstructure:"ssh_wait_timeout"` RawSSHWaitTimeout string `mapstructure:"ssh_wait_timeout"`
......
...@@ -25,6 +25,8 @@ type Builder struct { ...@@ -25,6 +25,8 @@ type Builder struct {
} }
type config struct { type config struct {
common.PackerConfig `mapstructure:",squash"`
DiskName string `mapstructure:"vmdk_name"` DiskName string `mapstructure:"vmdk_name"`
DiskSize uint `mapstructure:"disk_size"` DiskSize uint `mapstructure:"disk_size"`
FloppyFiles []string `mapstructure:"floppy_files"` FloppyFiles []string `mapstructure:"floppy_files"`
...@@ -50,10 +52,6 @@ type config struct { ...@@ -50,10 +52,6 @@ type config struct {
VNCPortMin uint `mapstructure:"vnc_port_min"` VNCPortMin uint `mapstructure:"vnc_port_min"`
VNCPortMax uint `mapstructure:"vnc_port_max"` VNCPortMax uint `mapstructure:"vnc_port_max"`
PackerBuildName string `mapstructure:"packer_build_name"`
PackerDebug bool `mapstructure:"packer_debug"`
PackerForce bool `mapstructure:"packer_force"`
RawBootWait string `mapstructure:"boot_wait"` RawBootWait string `mapstructure:"boot_wait"`
RawShutdownTimeout string `mapstructure:"shutdown_timeout"` RawShutdownTimeout string `mapstructure:"shutdown_timeout"`
RawSSHWaitTimeout string `mapstructure:"ssh_wait_timeout"` RawSSHWaitTimeout string `mapstructure:"ssh_wait_timeout"`
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment