Add support for setting labels on GCE instance

This commit is contained in:
Patrick Decat 2017-09-06 10:58:08 +02:00
parent 94fafe91ad
commit a7283f2281
4 changed files with 4 additions and 0 deletions

View File

@ -36,6 +36,7 @@ type Config struct {
ImageDescription string `mapstructure:"image_description"` ImageDescription string `mapstructure:"image_description"`
ImageFamily string `mapstructure:"image_family"` ImageFamily string `mapstructure:"image_family"`
InstanceName string `mapstructure:"instance_name"` InstanceName string `mapstructure:"instance_name"`
Labels map[string]string `mapstructure:"labels"`
MachineType string `mapstructure:"machine_type"` MachineType string `mapstructure:"machine_type"`
Metadata map[string]string `mapstructure:"metadata"` Metadata map[string]string `mapstructure:"metadata"`
Network string `mapstructure:"network"` Network string `mapstructure:"network"`

View File

@ -65,6 +65,7 @@ type InstanceConfig struct {
DiskSizeGb int64 DiskSizeGb int64
DiskType string DiskType string
Image *Image Image *Image
Labels map[string]string
MachineType string MachineType string
Metadata map[string]string Metadata map[string]string
Name string Name string

View File

@ -407,6 +407,7 @@ func (d *driverGCE) RunInstance(c *InstanceConfig) (<-chan error, error) {
}, },
}, },
GuestAccelerators: guestAccelerators, GuestAccelerators: guestAccelerators,
Labels: c.Labels,
MachineType: machineType.SelfLink, MachineType: machineType.SelfLink,
Metadata: &compute.Metadata{ Metadata: &compute.Metadata{
Items: metadata, Items: metadata,

View File

@ -106,6 +106,7 @@ func (s *StepCreateInstance) Run(state multistep.StateBag) multistep.StepAction
DiskSizeGb: c.DiskSizeGb, DiskSizeGb: c.DiskSizeGb,
DiskType: c.DiskType, DiskType: c.DiskType,
Image: sourceImage, Image: sourceImage,
Labels: c.Labels,
MachineType: c.MachineType, MachineType: c.MachineType,
Metadata: metadata, Metadata: metadata,
Name: name, Name: name,