Introduce a new configuration parameter instead

... so that one can have a different list compared to instances.
This commit is contained in:
Peter Mounce 2017-09-18 17:53:40 +01:00
parent e579b947b1
commit ac8eedf171
6 changed files with 9 additions and 5 deletions

View File

@ -35,6 +35,7 @@ type Config struct {
ImageName string `mapstructure:"image_name"`
ImageDescription string `mapstructure:"image_description"`
ImageFamily string `mapstructure:"image_family"`
ImageLabels map[string]string `mapstructure:"image_labels"`
InstanceName string `mapstructure:"instance_name"`
Labels map[string]string `mapstructure:"labels"`
MachineType string `mapstructure:"machine_type"`

View File

@ -11,7 +11,7 @@ import (
type Driver interface {
// CreateImage creates an image from the given disk in Google Compute
// Engine.
CreateImage(name, description, family, zone, disk string, labels map[string]string) (<-chan *Image, <-chan error)
CreateImage(name, description, family, zone, disk string, image_labels map[string]string) (<-chan *Image, <-chan error)
// DeleteImage deletes the image with the given name.
DeleteImage(name string) <-chan error

View File

@ -98,7 +98,7 @@ func NewDriverGCE(ui packer.Ui, p string, a *AccountFile) (Driver, error) {
}, nil
}
func (d *driverGCE) CreateImage(name, description, family, zone, disk string, labels map[string]string) (<-chan *Image, <-chan error) {
func (d *driverGCE) CreateImage(name, description, family, zone, disk string, image_labels map[string]string) (<-chan *Image, <-chan error) {
gce_image := &compute.Image{
Description: description,
Name: name,

View File

@ -81,7 +81,7 @@ type DriverMock struct {
WaitForInstanceErrCh <-chan error
}
func (d *DriverMock) CreateImage(name, description, family, zone, disk string, labels map[string]string) (<-chan *Image, <-chan error) {
func (d *DriverMock) CreateImage(name, description, family, zone, disk string, image_labels map[string]string) (<-chan *Image, <-chan error) {
d.CreateImageName = name
d.CreateImageDesc = description
d.CreateImageFamily = family

View File

@ -39,7 +39,7 @@ func (s *StepCreateImage) Run(state multistep.StateBag) multistep.StepAction {
imageCh, errCh := driver.CreateImage(
config.ImageName, config.ImageDescription, config.ImageFamily, config.Zone,
config.DiskName, config.Labels)
config.DiskName, config.ImageLabels)
var err error
select {
case err = <-errCh:

View File

@ -198,6 +198,9 @@ builder.
instead of a specific image name. The image family always returns its
latest image that is not deprecated.
- `image_labels` (object of key/value strings) - Key/value pair labels to
apply to the created image.
- `image_name` (string) - The unique name of the resulting image. Defaults to
`"packer-{{timestamp}}"`.
@ -205,7 +208,7 @@ builder.
this must be unique. Defaults to `"packer-{{uuid}}"`.
- `labels` (object of key/value strings) - Key/value pair labels to apply to
the launched instance and the created image.
the launched instance.
- `machine_type` (string) - The machine type. Defaults to `"n1-standard-1"`.