github.com/rothwerx/packer@v0.9.0/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  	Image       Image
    46  	MachineType string
    47  	Metadata    map[string]string
    48  	Name        string
    49  	Network     string
    50  	Subnetwork  string
    51  	Address     string
    52  	Preemptible bool
    53  	Tags        []string
    54  	Region      string
    55  	Zone        string
    56  }