diff --git a/builder/googlecompute/driver.go b/builder/googlecompute/driver.go index 60707ac84..70815c8cd 100644 --- a/builder/googlecompute/driver.go +++ b/builder/googlecompute/driver.go @@ -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) (<-chan *Image, <-chan error) + CreateImage(name, description, family, zone, disk string, labels map[string]string) (<-chan *Image, <-chan error) // DeleteImage deletes the image with the given name. DeleteImage(name string) <-chan error diff --git a/builder/googlecompute/driver_gce.go b/builder/googlecompute/driver_gce.go index 0df21eba6..432c0c333 100644 --- a/builder/googlecompute/driver_gce.go +++ b/builder/googlecompute/driver_gce.go @@ -98,11 +98,12 @@ func NewDriverGCE(ui packer.Ui, p string, a *AccountFile) (Driver, error) { }, nil } -func (d *driverGCE) CreateImage(name, description, family, zone, disk string) (<-chan *Image, <-chan error) { +func (d *driverGCE) CreateImage(name, description, family, zone, disk string, labels map[string]string) (<-chan *Image, <-chan error) { gce_image := &compute.Image{ Description: description, Name: name, Family: family, + Labels: labels, SourceDisk: fmt.Sprintf("%s%s/zones/%s/disks/%s", d.service.BasePath, d.projectId, zone, disk), SourceType: "RAW", } diff --git a/builder/googlecompute/step_create_image.go b/builder/googlecompute/step_create_image.go index 13339d82f..ec287ae16 100644 --- a/builder/googlecompute/step_create_image.go +++ b/builder/googlecompute/step_create_image.go @@ -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.DiskName, config.Labels) var err error select { case err = <-errCh: diff --git a/website/source/docs/builders/googlecompute.html.md b/website/source/docs/builders/googlecompute.html.md index dda8841dd..70001947d 100644 --- a/website/source/docs/builders/googlecompute.html.md +++ b/website/source/docs/builders/googlecompute.html.md @@ -205,7 +205,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. + the launched instance and the created image. - `machine_type` (string) - The machine type. Defaults to `"n1-standard-1"`.