From a7283f2281b0fee6899cb22206d851f0f8836b6f Mon Sep 17 00:00:00 2001 From: Patrick Decat Date: Wed, 6 Sep 2017 10:58:08 +0200 Subject: [PATCH] Add support for setting labels on GCE instance --- builder/googlecompute/config.go | 1 + builder/googlecompute/driver.go | 1 + builder/googlecompute/driver_gce.go | 1 + builder/googlecompute/step_create_instance.go | 1 + 4 files changed, 4 insertions(+) diff --git a/builder/googlecompute/config.go b/builder/googlecompute/config.go index 99c52a704..c4aa79d22 100644 --- a/builder/googlecompute/config.go +++ b/builder/googlecompute/config.go @@ -36,6 +36,7 @@ type Config struct { ImageDescription string `mapstructure:"image_description"` ImageFamily string `mapstructure:"image_family"` InstanceName string `mapstructure:"instance_name"` + Labels map[string]string `mapstructure:"labels"` MachineType string `mapstructure:"machine_type"` Metadata map[string]string `mapstructure:"metadata"` Network string `mapstructure:"network"` diff --git a/builder/googlecompute/driver.go b/builder/googlecompute/driver.go index a93559e92..60707ac84 100644 --- a/builder/googlecompute/driver.go +++ b/builder/googlecompute/driver.go @@ -65,6 +65,7 @@ type InstanceConfig struct { DiskSizeGb int64 DiskType string Image *Image + Labels map[string]string MachineType string Metadata map[string]string Name string diff --git a/builder/googlecompute/driver_gce.go b/builder/googlecompute/driver_gce.go index 28cb08f6a..0df21eba6 100644 --- a/builder/googlecompute/driver_gce.go +++ b/builder/googlecompute/driver_gce.go @@ -407,6 +407,7 @@ func (d *driverGCE) RunInstance(c *InstanceConfig) (<-chan error, error) { }, }, GuestAccelerators: guestAccelerators, + Labels: c.Labels, MachineType: machineType.SelfLink, Metadata: &compute.Metadata{ Items: metadata, diff --git a/builder/googlecompute/step_create_instance.go b/builder/googlecompute/step_create_instance.go index 97b659a9d..a4509354e 100644 --- a/builder/googlecompute/step_create_instance.go +++ b/builder/googlecompute/step_create_instance.go @@ -106,6 +106,7 @@ func (s *StepCreateInstance) Run(state multistep.StateBag) multistep.StepAction DiskSizeGb: c.DiskSizeGb, DiskType: c.DiskType, Image: sourceImage, + Labels: c.Labels, MachineType: c.MachineType, Metadata: metadata, Name: name,