googlecompute

package
v0.8.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2015 License: MPL-2.0 Imports: 24 Imported by: 0

Documentation

Overview

The googlecompute package contains a packer.Builder implementation that builds images for Google Compute Engine.

Index

Constants

View Source
const BuilderId = "packer.googlecompute"

The unique ID for this builder.

Variables

View Source
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.

func (*Artifact) BuilderId

func (*Artifact) BuilderId() string

BuilderId returns the builder Id.

func (*Artifact) Destroy

func (a *Artifact) Destroy() error

Destroy destroys the GCE image represented by the artifact.

func (*Artifact) Files

func (*Artifact) Files() []string

Files returns the files represented by the artifact.

func (*Artifact) Id

func (a *Artifact) Id() string

Id returns the GCE image name.

func (*Artifact) State added in v0.7.2

func (a *Artifact) State(name string) interface{}

func (*Artifact) String

func (a *Artifact) String() string

String returns the string representation of the artifact.

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder represents a Packer Builder.

func (*Builder) Cancel

func (b *Builder) Cancel()

Cancel.

func (*Builder) Prepare

func (b *Builder) Prepare(raws ...interface{}) ([]string, error)

Prepare processes the build configuration parameters.

func (*Builder) Run

func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packer.Artifact, error)

Run executes a googlecompute Packer build and returns a packer.Artifact representing a GCE machine image.

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.

func NewConfig

func NewConfig(raws ...interface{}) (*Config, []string, error)

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.

func NewDriverGCE

func NewDriverGCE(ui packer.Ui, p string, a *accountFile) (Driver, error)

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) GetNatIP

func (d *DriverMock) GetNatIP(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 Image added in v0.7.0

type Image struct {
	Name      string
	ProjectId string
}

type InstanceConfig

type InstanceConfig struct {
	Description string
	DiskSizeGb  int64
	Image       Image
	MachineType string
	Metadata    map[string]string
	Name        string
	Network     string
	Tags        []string
	Zone        string
}

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

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

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

Run executes the Packer build step that creates a GCE instance.

type StepCreateSSHKey

type StepCreateSSHKey struct {
	Debug        bool
	DebugKeyPath string
}

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

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

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

Run executes the Packer build step that tears down a GCE instance.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL