github.com/kikitux/packer@v0.10.1-0.20160322154024-6237df566f9f/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 // GetInternalIP gets the GCE-internal IP address for the instance. 28 GetInternalIP(zone, name string) (string, error) 29 30 // RunInstance takes the given config and launches an instance. 31 RunInstance(*InstanceConfig) (<-chan error, error) 32 33 // WaitForInstance waits for an instance to reach the given state. 34 WaitForInstance(state, zone, name string) <-chan error 35 } 36 37 type Image struct { 38 Name string 39 ProjectId string 40 } 41 42 type InstanceConfig struct { 43 Description string 44 DiskSizeGb int64 45 DiskType string 46 Image Image 47 MachineType string 48 Metadata map[string]string 49 Name string 50 Network string 51 Subnetwork string 52 Address string 53 Preemptible bool 54 Tags []string 55 Region string 56 Zone string 57 }