Documentation
¶
Overview ¶
The googlecompute package contains a packer.Builder implementation that builds images for Google Compute Engine.
Index ¶
- Constants
- Variables
- type Artifact
- type Builder
- type Config
- type Driver
- type DriverMock
- func (d *DriverMock) CreateImage(name, description, zone, disk string) <-chan error
- func (d *DriverMock) DeleteDisk(zone, name string) (<-chan error, error)
- func (d *DriverMock) DeleteImage(name string) <-chan error
- func (d *DriverMock) DeleteInstance(zone, name string) (<-chan error, error)
- func (d *DriverMock) GetInternalIP(zone, name string) (string, error)
- func (d *DriverMock) GetNatIP(zone, name string) (string, error)
- func (d *DriverMock) ImageExists(name string) bool
- func (d *DriverMock) RunInstance(c *InstanceConfig) (<-chan error, error)
- func (d *DriverMock) WaitForInstance(state, zone, name string) <-chan error
- type Image
- type InstanceConfig
- type StepCheckExistingImage
- type StepCreateImage
- type StepCreateInstance
- type StepCreateSSHKey
- type StepInstanceInfo
- type StepTeardownInstance
Constants ¶
const BuilderId = "packer.googlecompute"
The unique ID for this builder.
Variables ¶
var DriverScopes = []string{"https://www.googleapis.com/auth/compute", "https://www.googleapis.com/auth/devstorage.full_control"}
Functions ¶
This section is empty.
Types ¶
type Artifact ¶
type Artifact struct {
// contains filtered or unexported fields
}
Artifact represents a GCE image as the result of a Packer build.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder represents a Packer Builder.
type Config ¶
type Config struct {
common.PackerConfig `mapstructure:",squash"`
Comm communicator.Config `mapstructure:",squash"`
AccountFile string `mapstructure:"account_file"`
ProjectId string `mapstructure:"project_id"`
DiskName string `mapstructure:"disk_name"`
DiskSizeGb int64 `mapstructure:"disk_size"`
ImageName string `mapstructure:"image_name"`
ImageDescription string `mapstructure:"image_description"`
InstanceName string `mapstructure:"instance_name"`
MachineType string `mapstructure:"machine_type"`
Metadata map[string]string `mapstructure:"metadata"`
Network string `mapstructure:"network"`
SourceImage string `mapstructure:"source_image"`
SourceImageProjectId string `mapstructure:"source_image_project_id"`
RawStateTimeout string `mapstructure:"state_timeout"`
Tags []string `mapstructure:"tags"`
UseInternalIP bool `mapstructure:"use_internal_ip"`
Zone string `mapstructure:"zone"`
// contains filtered or unexported fields
}
Config is the configuration structure for the GCE builder. It stores both the publicly settable state as well as the privately generated state of the config object.
type Driver ¶
type Driver interface {
// ImageExists returns true if the specified image exists. If an error
// occurs calling the API, this method returns false.
ImageExists(name string) bool
// 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)
// GetInternalIP gets the GCE-internal IP address for the instance.
GetInternalIP(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
}
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 DriverMock ¶
type DriverMock struct {
ImageExistsName string
ImageExistsResult bool
CreateImageName string
CreateImageDesc string
CreateImageZone string
CreateImageDisk string
CreateImageErrCh <-chan error
DeleteImageName string
DeleteImageErrCh <-chan error
DeleteInstanceZone string
DeleteInstanceName string
DeleteInstanceErrCh <-chan error
DeleteInstanceErr error
DeleteDiskZone string
DeleteDiskName string
DeleteDiskErrCh <-chan error
DeleteDiskErr error
GetNatIPZone string
GetNatIPName string
GetNatIPResult string
GetNatIPErr error
GetInternalIPZone string
GetInternalIPName string
GetInternalIPResult string
GetInternalIPErr error
RunInstanceConfig *InstanceConfig
RunInstanceErrCh <-chan error
RunInstanceErr error
WaitForInstanceState string
WaitForInstanceZone string
WaitForInstanceName string
WaitForInstanceErrCh <-chan error
}
DriverMock is a Driver implementation that is a mocked out so that it can be used for tests.
func (*DriverMock) CreateImage ¶
func (d *DriverMock) CreateImage(name, description, zone, disk string) <-chan error
func (*DriverMock) DeleteDisk ¶ added in v0.7.5
func (d *DriverMock) DeleteDisk(zone, name string) (<-chan error, error)
func (*DriverMock) DeleteImage ¶
func (d *DriverMock) DeleteImage(name string) <-chan error
func (*DriverMock) DeleteInstance ¶
func (d *DriverMock) DeleteInstance(zone, name string) (<-chan error, error)
func (*DriverMock) GetInternalIP ¶ added in v0.8.0
func (d *DriverMock) GetInternalIP(zone, name string) (string, error)
func (*DriverMock) ImageExists ¶ added in v0.7.5
func (d *DriverMock) ImageExists(name string) bool
func (*DriverMock) RunInstance ¶
func (d *DriverMock) RunInstance(c *InstanceConfig) (<-chan error, error)
func (*DriverMock) WaitForInstance ¶
func (d *DriverMock) WaitForInstance(state, zone, name string) <-chan error
type InstanceConfig ¶
type StepCheckExistingImage ¶ added in v0.7.5
type StepCheckExistingImage int
StepCheckExistingImage represents a Packer build step that checks if the target image already exists, and aborts immediately if so.
func (*StepCheckExistingImage) Cleanup ¶ added in v0.7.5
func (s *StepCheckExistingImage) Cleanup(state multistep.StateBag)
Cleanup.
func (*StepCheckExistingImage) Run ¶ added in v0.7.5
func (s *StepCheckExistingImage) Run(state multistep.StateBag) multistep.StepAction
Run executes the Packer build step that checks if the image already exists.
type StepCreateImage ¶
type StepCreateImage int
StepCreateImage represents a Packer build step that creates GCE machine images.
func (*StepCreateImage) Cleanup ¶
func (s *StepCreateImage) Cleanup(state multistep.StateBag)
Cleanup.
func (*StepCreateImage) Run ¶
func (s *StepCreateImage) Run(state multistep.StateBag) multistep.StepAction
Run executes the Packer build step that creates a GCE machine image.
The image is created from the persistent disk used by the instance. The instance must be deleted and the disk retained before doing this step.
type StepCreateInstance ¶
type StepCreateInstance struct {
Debug bool
}
StepCreateInstance represents a Packer build step that creates GCE instances.
func (*StepCreateInstance) Cleanup ¶
func (s *StepCreateInstance) Cleanup(state multistep.StateBag)
Cleanup destroys the GCE instance created during the image creation process.
func (*StepCreateInstance) Run ¶
func (s *StepCreateInstance) Run(state multistep.StateBag) multistep.StepAction
Run executes the Packer build step that creates a GCE instance.
type StepCreateSSHKey ¶
StepCreateSSHKey represents a Packer build step that generates SSH key pairs.
func (*StepCreateSSHKey) Cleanup ¶
func (s *StepCreateSSHKey) Cleanup(state multistep.StateBag)
Nothing to clean up. SSH keys are associated with a single GCE instance.
func (*StepCreateSSHKey) Run ¶
func (s *StepCreateSSHKey) Run(state multistep.StateBag) multistep.StepAction
Run executes the Packer build step that generates SSH key pairs.
type StepInstanceInfo ¶
type StepInstanceInfo struct {
Debug bool
// contains filtered or unexported fields
}
stepInstanceInfo represents a Packer build step that gathers GCE instance info.
func (*StepInstanceInfo) Cleanup ¶
func (s *StepInstanceInfo) Cleanup(state multistep.StateBag)
Cleanup.
func (*StepInstanceInfo) Run ¶
func (s *StepInstanceInfo) Run(state multistep.StateBag) multistep.StepAction
Run executes the Packer build step that gathers GCE instance info.
type StepTeardownInstance ¶ added in v0.7.5
type StepTeardownInstance struct {
Debug bool
}
StepTeardownInstance represents a Packer build step that tears down GCE instances.
func (*StepTeardownInstance) Cleanup ¶ added in v0.7.5
func (s *StepTeardownInstance) Cleanup(state multistep.StateBag)
Deleting the instance does not remove the boot disk. This cleanup removes the disk.
func (*StepTeardownInstance) Run ¶ added in v0.7.5
func (s *StepTeardownInstance) Run(state multistep.StateBag) multistep.StepAction
Run executes the Packer build step that tears down a GCE instance.