Adding OnHostMaintenance option for googlecompue builder
This commit is contained in:
parent
e04f87effe
commit
bab590c177
|
@ -39,6 +39,7 @@ type Config struct {
|
||||||
Network string `mapstructure:"network"`
|
Network string `mapstructure:"network"`
|
||||||
NetworkProjectId string `mapstructure:"network_project_id"`
|
NetworkProjectId string `mapstructure:"network_project_id"`
|
||||||
OmitExternalIP bool `mapstructure:"omit_external_ip"`
|
OmitExternalIP bool `mapstructure:"omit_external_ip"`
|
||||||
|
OnHostMaintenance string `mapstructure:"on_host_maintenance"`
|
||||||
Preemptible bool `mapstructure:"preemptible"`
|
Preemptible bool `mapstructure:"preemptible"`
|
||||||
RawStateTimeout string `mapstructure:"state_timeout"`
|
RawStateTimeout string `mapstructure:"state_timeout"`
|
||||||
Region string `mapstructure:"region"`
|
Region string `mapstructure:"region"`
|
||||||
|
@ -92,6 +93,12 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
||||||
if c.ImageDescription == "" {
|
if c.ImageDescription == "" {
|
||||||
c.ImageDescription = "Created by Packer"
|
c.ImageDescription = "Created by Packer"
|
||||||
}
|
}
|
||||||
|
// Possible values:
|
||||||
|
// "MIGRATE"
|
||||||
|
// "TERMINATE"
|
||||||
|
if c.OnHostMaintenance == "" {
|
||||||
|
c.OnHostMaintenance = "MIGRATE"
|
||||||
|
}
|
||||||
|
|
||||||
if c.ImageName == "" {
|
if c.ImageName == "" {
|
||||||
img, err := interpolate.Render("packer-{{timestamp}}", nil)
|
img, err := interpolate.Render("packer-{{timestamp}}", nil)
|
||||||
|
|
|
@ -104,6 +104,21 @@ func TestConfigPrepare(t *testing.T) {
|
||||||
"SO VERY BAD",
|
"SO VERY BAD",
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"on_host_maintenance",
|
||||||
|
nil,
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"on_host_maintenance",
|
||||||
|
"TERMINATE",
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"on_host_maintenance",
|
||||||
|
"SO VERY BAD",
|
||||||
|
false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"preemptible",
|
"preemptible",
|
||||||
nil,
|
nil,
|
||||||
|
|
|
@ -69,6 +69,7 @@ type InstanceConfig struct {
|
||||||
Network string
|
Network string
|
||||||
NetworkProjectId string
|
NetworkProjectId string
|
||||||
OmitExternalIP bool
|
OmitExternalIP bool
|
||||||
|
OnHostMaintenance string
|
||||||
Preemptible bool
|
Preemptible bool
|
||||||
Region string
|
Region string
|
||||||
Scopes []string
|
Scopes []string
|
||||||
|
|
|
@ -386,6 +386,7 @@ func (d *driverGCE) RunInstance(c *InstanceConfig) (<-chan error, error) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Scheduling: &compute.Scheduling{
|
Scheduling: &compute.Scheduling{
|
||||||
|
OnHostMaintenance: c.OnHostMaintenance,
|
||||||
Preemptible: c.Preemptible,
|
Preemptible: c.Preemptible,
|
||||||
},
|
},
|
||||||
ServiceAccounts: []*compute.ServiceAccount{
|
ServiceAccounts: []*compute.ServiceAccount{
|
||||||
|
|
|
@ -110,6 +110,7 @@ func (s *StepCreateInstance) Run(state multistep.StateBag) multistep.StepAction
|
||||||
Network: c.Network,
|
Network: c.Network,
|
||||||
NetworkProjectId: c.NetworkProjectId,
|
NetworkProjectId: c.NetworkProjectId,
|
||||||
OmitExternalIP: c.OmitExternalIP,
|
OmitExternalIP: c.OmitExternalIP,
|
||||||
|
OnHostMaintenance: c.OnHostMaintenance,
|
||||||
Preemptible: c.Preemptible,
|
Preemptible: c.Preemptible,
|
||||||
Region: c.Region,
|
Region: c.Region,
|
||||||
ServiceAccountEmail: c.Account.ClientEmail,
|
ServiceAccountEmail: c.Account.ClientEmail,
|
||||||
|
|
Loading…
Reference in New Issue