Merge pull request #3336 from mitchellh/f-google-disk-type

Add disk_type for google compute, courtesy @meatballhat
This commit is contained in:
Chris Bednarski 2016-03-10 14:58:30 -08:00
commit 0a97874cdd
5 changed files with 10 additions and 0 deletions

View File

@ -25,6 +25,7 @@ type Config struct {
DiskName string `mapstructure:"disk_name"`
DiskSizeGb int64 `mapstructure:"disk_size"`
DiskType string `mapstructure:"disk_type"`
ImageName string `mapstructure:"image_name"`
ImageDescription string `mapstructure:"image_description"`
InstanceName string `mapstructure:"instance_name"`
@ -74,6 +75,10 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
c.DiskSizeGb = 10
}
if c.DiskType == "" {
c.DiskType = "pd-standard"
}
if c.ImageDescription == "" {
c.ImageDescription = "Created by Packer"
}

View File

@ -42,6 +42,7 @@ type Image struct {
type InstanceConfig struct {
Description string
DiskSizeGb int64
DiskType string
Image Image
MachineType string
Metadata map[string]string

View File

@ -274,6 +274,7 @@ func (d *driverGCE) RunInstance(c *InstanceConfig) (<-chan error, error) {
InitializeParams: &compute.AttachedDiskInitializeParams{
SourceImage: image.SelfLink,
DiskSizeGb: c.DiskSizeGb,
DiskType: fmt.Sprintf("zones/%s/diskTypes/%s", zone.Name, c.DiskType),
},
},
},

View File

@ -54,6 +54,7 @@ func (s *StepCreateInstance) Run(state multistep.StateBag) multistep.StepAction
errCh, err := driver.RunInstance(&InstanceConfig{
Description: "New instance created by Packer",
DiskSizeGb: config.DiskSizeGb,
DiskType: config.DiskType,
Image: config.getImage(),
MachineType: config.MachineType,
Metadata: config.getInstanceMetadata(sshPublicKey),

View File

@ -124,6 +124,8 @@ builder.
- `disk_size` (integer) - The size of the disk in GB. This defaults to `10`,
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
`"packer-{{timestamp}}"`.