supported preemptible in googlecompute builder

This commit is contained in:
YAMADA Tsuyoshi 2015-12-05 05:13:35 +09:00
parent b97f343776
commit afd314959b
4 changed files with 6 additions and 0 deletions

View File

@ -31,6 +31,7 @@ type Config struct {
MachineType string `mapstructure:"machine_type"`
Metadata map[string]string `mapstructure:"metadata"`
Network string `mapstructure:"network"`
Preemptible bool `mapstructure:"preemptible"`
SourceImage string `mapstructure:"source_image"`
SourceImageProjectId string `mapstructure:"source_image_project_id"`
RawStateTimeout string `mapstructure:"state_timeout"`

View File

@ -47,6 +47,7 @@ type InstanceConfig struct {
Metadata map[string]string
Name string
Network string
Preemptible bool
Tags []string
Zone string
}

View File

@ -255,6 +255,9 @@ func (d *driverGCE) RunInstance(c *InstanceConfig) (<-chan error, error) {
Network: network.SelfLink,
},
},
Scheduling: &compute.Scheduling{
Preemptible: c.Preemptible,
},
ServiceAccounts: []*compute.ServiceAccount{
&compute.ServiceAccount{
Email: "default",

View File

@ -59,6 +59,7 @@ func (s *StepCreateInstance) Run(state multistep.StateBag) multistep.StepAction
Metadata: config.getInstanceMetadata(sshPublicKey),
Name: name,
Network: config.Network,
Preemptible: config.Preemptible,
Tags: config.Tags,
Zone: config.Zone,
})