Make the googlecompute builder label the resulting image.
... so that it's possible to find images matching particular characteristics more easily.
This commit is contained in:
parent
4ce381cae7
commit
8789ae72e8
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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"`.
|
||||
|
||||
|
|
Loading…
Reference in New Issue