github.com/daniellockard/packer@v0.7.6-0.20141210173435-5a9390934716/builder/googlecompute/driver.go (about) 1 package googlecompute 2 3 // Driver is the interface that has to be implemented to communicate 4 // with GCE. The Driver interface exists mostly to allow a mock implementation 5 // to be used to test the steps. 6 type Driver interface { 7 // ImageExists returns true if the specified image exists. If an error 8 // occurs calling the API, this method returns false. 9 ImageExists(name string) bool 10 11 // CreateImage creates an image from the given disk in Google Compute 12 // Engine. 13 CreateImage(name, description, zone, disk string) <-chan error 14 15 // DeleteImage deletes the image with the given name. 16 DeleteImage(name string) <-chan error 17 18 // DeleteInstance deletes the given instance, keeping the boot disk. 19 DeleteInstance(zone, name string) (<-chan error, error) 20 21 // DeleteDisk deletes the disk with the given name. 22 DeleteDisk(zone, name string) (<-chan error, error) 23 24 // GetNatIP gets the NAT IP address for the instance. 25 GetNatIP(zone, name string) (string, error) 26 27 // RunInstance takes the given config and launches an instance. 28 RunInstance(*InstanceConfig) (<-chan error, error) 29 30 // WaitForInstance waits for an instance to reach the given state. 31 WaitForInstance(state, zone, name string) <-chan error 32 } 33 34 type Image struct { 35 Name string 36 ProjectId string 37 } 38 39 type InstanceConfig struct { 40 Description string 41 DiskSizeGb int64 42 Image Image 43 MachineType string 44 Metadata map[string]string 45 Name string 46 Network string 47 Tags []string 48 Zone string 49 }