Documentation ¶
Overview ¶
The googlecompute package contains a packer.Builder implementation that builds images for Google Compute Engine.
Index ¶
- Constants
- type Artifact
- type Builder
- type Config
- type Driver
- type DriverMock
- func (d *DriverMock) CreateImage(name, description, url string) <-chan error
- func (d *DriverMock) DeleteImage(name string) <-chan error
- func (d *DriverMock) DeleteInstance(zone, name string) (<-chan error, error)
- func (d *DriverMock) GetNatIP(zone, name string) (string, error)
- func (d *DriverMock) RunInstance(c *InstanceConfig) (<-chan error, error)
- func (d *DriverMock) WaitForInstance(state, zone, name string) <-chan error
- type InstanceConfig
- type StepCreateImage
- type StepCreateInstance
- type StepCreateSSHKey
- type StepInstanceInfo
- type StepRegisterImage
- type StepUpdateGsutil
- type StepUploadImage
Constants ¶
const BuilderId = "packer.googlecompute"
The unique ID for this builder.
const DriverScopes string = "https://www.googleapis.com/auth/compute " +
"https://www.googleapis.com/auth/devstorage.full_control"
Variables ¶
This section is empty.
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"` BucketName string `mapstructure:"bucket_name"` ClientSecretsFile string `mapstructure:"client_secrets_file"` ImageName string `mapstructure:"image_name"` ImageDescription string `mapstructure:"image_description"` MachineType string `mapstructure:"machine_type"` Metadata map[string]string `mapstructure:"metadata"` Network string `mapstructure:"network"` Passphrase string `mapstructure:"passphrase"` PrivateKeyFile string `mapstructure:"private_key_file"` ProjectId string `mapstructure:"project_id"` SourceImage string `mapstructure:"source_image"` SSHUsername string `mapstructure:"ssh_username"` SSHPort uint `mapstructure:"ssh_port"` RawSSHTimeout string `mapstructure:"ssh_timeout"` RawStateTimeout string `mapstructure:"state_timeout"` Tags []string `mapstructure:"tags"` 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 { // CreateImage creates an image with the given URL in Google Storage. CreateImage(name, description, url string) <-chan error // DeleteImage deletes the image with the given name. DeleteImage(name string) <-chan error // DeleteInstance deletes the given instance. DeleteInstance(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 }
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 { CreateImageName string CreateImageDesc string CreateImageURL string CreateImageErrCh <-chan error DeleteImageName string DeleteImageErrCh <-chan error DeleteInstanceZone string DeleteInstanceName string DeleteInstanceErrCh <-chan error DeleteInstanceErr error GetNatIPZone string GetNatIPName string GetNatIPResult string GetNatIPErr 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, url string) <-chan 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) 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 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)
func (*StepCreateImage) Run ¶
func (s *StepCreateImage) Run(state multistep.StateBag) multistep.StepAction
Run executes the Packer build step that creates a GCE machine image.
Currently the only way to create a GCE image is to run the gcimagebundle command on the running GCE instance.
type StepCreateInstance ¶
type StepCreateInstance struct {
// contains filtered or unexported fields
}
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 ¶
type StepCreateSSHKey int
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 int
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 StepRegisterImage ¶
type StepRegisterImage int
StepRegisterImage represents a Packer build step that registers GCE machine images.
func (*StepRegisterImage) Cleanup ¶
func (s *StepRegisterImage) Cleanup(state multistep.StateBag)
Cleanup.
func (*StepRegisterImage) Run ¶
func (s *StepRegisterImage) Run(state multistep.StateBag) multistep.StepAction
Run executes the Packer build step that registers a GCE machine image.
type StepUpdateGsutil ¶
type StepUpdateGsutil int
StepUpdateGsutil represents a Packer build step that updates the gsutil utility to the latest version available.
func (*StepUpdateGsutil) Cleanup ¶
func (s *StepUpdateGsutil) Cleanup(state multistep.StateBag)
Cleanup.
func (*StepUpdateGsutil) Run ¶
func (s *StepUpdateGsutil) Run(state multistep.StateBag) multistep.StepAction
Run executes the Packer build step that updates the gsutil utility to the latest version available.
This step is required to prevent the image creation process from hanging; the image creation process utilizes the gcimagebundle cli tool which will prompt to update gsutil if a newer version is available.
type StepUploadImage ¶
type StepUploadImage int
StepUploadImage represents a Packer build step that uploads GCE machine images.
func (*StepUploadImage) Cleanup ¶
func (s *StepUploadImage) Cleanup(state multistep.StateBag)
Cleanup.
func (*StepUploadImage) Run ¶
func (s *StepUploadImage) Run(state multistep.StateBag) multistep.StepAction
Run executes the Packer build step that uploads a GCE machine image.