The new flow: 1) Provision the instance 2) Tear down the instance, but keep the boot disk 3) Create an image from the disk 4) Tear down the disk The step to update gcloud is no longer needed, since gceimagebundle isn't used anymore. Fixes #1507 and addresses https://github.com/mitchellh/packer/issues/1447#issuecomment-61610235.
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package googlecompute
|
|
|
|
// Driver is the interface that has to be implemented to communicate
|
|
// with GCE. The Driver interface exists mostly to allow a mock implementation
|
|
// to be used to test the steps.
|
|
type Driver interface {
|
|
// CreateImage creates an image from the given disk in Google Compute
|
|
// Engine.
|
|
CreateImage(name, description, zone, disk string) <-chan error
|
|
|
|
// DeleteImage deletes the image with the given name.
|
|
DeleteImage(name string) <-chan error
|
|
|
|
// DeleteInstance deletes the given instance, keeping the boot disk.
|
|
DeleteInstance(zone, name string) (<-chan error, error)
|
|
|
|
// DeleteDisk deletes the disk with the given name.
|
|
DeleteDisk(zone, name string) (<-chan error, error)
|
|
|
|
// GetNatIP gets the NAT IP address for the instance.
|
|
GetNatIP(zone, name string) (string, error)
|
|
|
|
// RunInstance takes the given config and launches an instance.
|
|
RunInstance(*InstanceConfig) (<-chan error, error)
|
|
|
|
// WaitForInstance waits for an instance to reach the given state.
|
|
WaitForInstance(state, zone, name string) <-chan error
|
|
}
|
|
|
|
type Image struct {
|
|
Name string
|
|
ProjectId string
|
|
}
|
|
|
|
type InstanceConfig struct {
|
|
Description string
|
|
DiskSizeGb int64
|
|
Image Image
|
|
MachineType string
|
|
Metadata map[string]string
|
|
Name string
|
|
Network string
|
|
Tags []string
|
|
Zone string
|
|
}
|