Merge pull request #3336 from mitchellh/f-google-disk-type
Add disk_type for google compute, courtesy @meatballhat
This commit is contained in:
commit
0a97874cdd
|
@ -25,6 +25,7 @@ type Config struct {
|
||||||
|
|
||||||
DiskName string `mapstructure:"disk_name"`
|
DiskName string `mapstructure:"disk_name"`
|
||||||
DiskSizeGb int64 `mapstructure:"disk_size"`
|
DiskSizeGb int64 `mapstructure:"disk_size"`
|
||||||
|
DiskType string `mapstructure:"disk_type"`
|
||||||
ImageName string `mapstructure:"image_name"`
|
ImageName string `mapstructure:"image_name"`
|
||||||
ImageDescription string `mapstructure:"image_description"`
|
ImageDescription string `mapstructure:"image_description"`
|
||||||
InstanceName string `mapstructure:"instance_name"`
|
InstanceName string `mapstructure:"instance_name"`
|
||||||
|
@ -74,6 +75,10 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
||||||
c.DiskSizeGb = 10
|
c.DiskSizeGb = 10
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.DiskType == "" {
|
||||||
|
c.DiskType = "pd-standard"
|
||||||
|
}
|
||||||
|
|
||||||
if c.ImageDescription == "" {
|
if c.ImageDescription == "" {
|
||||||
c.ImageDescription = "Created by Packer"
|
c.ImageDescription = "Created by Packer"
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ type Image struct {
|
||||||
type InstanceConfig struct {
|
type InstanceConfig struct {
|
||||||
Description string
|
Description string
|
||||||
DiskSizeGb int64
|
DiskSizeGb int64
|
||||||
|
DiskType string
|
||||||
Image Image
|
Image Image
|
||||||
MachineType string
|
MachineType string
|
||||||
Metadata map[string]string
|
Metadata map[string]string
|
||||||
|
|
|
@ -274,6 +274,7 @@ func (d *driverGCE) RunInstance(c *InstanceConfig) (<-chan error, error) {
|
||||||
InitializeParams: &compute.AttachedDiskInitializeParams{
|
InitializeParams: &compute.AttachedDiskInitializeParams{
|
||||||
SourceImage: image.SelfLink,
|
SourceImage: image.SelfLink,
|
||||||
DiskSizeGb: c.DiskSizeGb,
|
DiskSizeGb: c.DiskSizeGb,
|
||||||
|
DiskType: fmt.Sprintf("zones/%s/diskTypes/%s", zone.Name, c.DiskType),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -54,6 +54,7 @@ func (s *StepCreateInstance) Run(state multistep.StateBag) multistep.StepAction
|
||||||
errCh, err := driver.RunInstance(&InstanceConfig{
|
errCh, err := driver.RunInstance(&InstanceConfig{
|
||||||
Description: "New instance created by Packer",
|
Description: "New instance created by Packer",
|
||||||
DiskSizeGb: config.DiskSizeGb,
|
DiskSizeGb: config.DiskSizeGb,
|
||||||
|
DiskType: config.DiskType,
|
||||||
Image: config.getImage(),
|
Image: config.getImage(),
|
||||||
MachineType: config.MachineType,
|
MachineType: config.MachineType,
|
||||||
Metadata: config.getInstanceMetadata(sshPublicKey),
|
Metadata: config.getInstanceMetadata(sshPublicKey),
|
||||||
|
|
|
@ -124,6 +124,8 @@ builder.
|
||||||
- `disk_size` (integer) - The size of the disk in GB. This defaults to `10`,
|
- `disk_size` (integer) - The size of the disk in GB. This defaults to `10`,
|
||||||
which is 10GB.
|
which is 10GB.
|
||||||
|
|
||||||
|
- `disk_type` (string) - Type of disk used to back your instance, like `pd-ssd` or `pd-standard`. Defaults to `pd-standard`.
|
||||||
|
|
||||||
- `image_name` (string) - The unique name of the resulting image. Defaults to
|
- `image_name` (string) - The unique name of the resulting image. Defaults to
|
||||||
`"packer-{{timestamp}}"`.
|
`"packer-{{timestamp}}"`.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue