Documentation
¶
Overview ¶
Package cloud provides different implementations for cloud providers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInstanceNotFound = errors.New("could not find instance")
ErrInstanceNotFound is returned as an error from Provider.Get() or Provider.Destroy() if an instance with the given ID doesn't exist.
Functions ¶
This section is empty.
Types ¶
type CreateAttributes ¶
type CreateAttributes struct { ImageName string InstanceType InstanceType PublicSSHKey string }
CreateAttributes contains the attributes needed to start an instance.
type FakeProvider ¶
type FakeProvider struct {
// contains filtered or unexported fields
}
FakeProvider is an in-memory Provider suitable for tests.
func (*FakeProvider) Create ¶
func (p *FakeProvider) Create(id string, attrs CreateAttributes) (Instance, error)
Create creates an instance in the fake provider.
func (*FakeProvider) Destroy ¶
func (p *FakeProvider) Destroy(id string) error
Destroy deletes the instance with the given ID. Returns an error if an instance with the given ID doesn't exist.
func (*FakeProvider) Get ¶
func (p *FakeProvider) Get(id string) (Instance, error)
Get returns the instance with the given ID, or an error if the instance wasn't found
func (*FakeProvider) List ¶
func (p *FakeProvider) List() ([]Instance, error)
List returns all the instances in the fake provider.
func (*FakeProvider) MarkRunning ¶
func (p *FakeProvider) MarkRunning(id string)
MarkRunning marks a VM as running and gives it a random IP address.
type GCEAccountJSON ¶
type GCEAccountJSON struct { ClientEmail string `json:"client_email"` PrivateKey string `json:"private_key"` TokenURI string `json:"token_uri"` }
GCEAccountJSON represents the JSON key file received from GCE when creating a new key for a service account.
type GCEProvider ¶
type GCEProvider struct {
// contains filtered or unexported fields
}
GCEProvider is an implementation of cloud.Provider backed by Google Compute Engine.
func NewGCEProvider ¶
func NewGCEProvider(conf GCEProviderConfiguration) (*GCEProvider, error)
NewGCEProvider creates a new GCEProvider with the given configuration.
func (*GCEProvider) Create ¶
func (p *GCEProvider) Create(id string, attr CreateAttributes) (Instance, error)
Create creates a new instance with the given ID and using the given attributes.
func (*GCEProvider) Destroy ¶
func (p *GCEProvider) Destroy(id string) error
Destroy terminates and removes the instance with the given ID. Returns ErrInstanceNotFound if an instance with the given ID wasn't found, or some other error if another error occurred. Does not wait for the instance to terminate, will return as soon as the destroy job is enqueued with GCE.
func (*GCEProvider) Get ¶
func (p *GCEProvider) Get(id string) (Instance, error)
Get retrieves information about the instance with the given name from Google Compute Engine. Return ErrInstanceNotFound if an instance with the given ID wasn't found, or some other error if we were unable to get information about the instance.
func (*GCEProvider) List ¶
func (p *GCEProvider) List() ([]Instance, error)
List returns a list of all instances on Google Compute Engine that were created by Cloud Brain.
type GCEProviderConfiguration ¶
type GCEProviderConfiguration struct { AccountJSON GCEAccountJSON `json:"account_json"` ProjectID string `json:"project_id"` ImageProjectID string `json:"image_project_id"` Zone string `json:"zone"` StandardMachineType string `json:"standard_machine_type"` PremiumMachineType string `json:"premium_machine_type"` Network string `json:"network"` DiskSize int64 `json:"disk_size"` AutoImplodeTime time.Duration `json:"auto_implode_time"` AutoImplode bool `json:"auto_implode"` Preemptible bool `json:"preemptible"` }
GCEProviderConfiguration contains all the configuration needed to create a GCEProvider.
type Instance ¶
type Instance struct { ID string State InstanceState IPAddress string UpstreamID string ErrorReason string }
An Instance is a single compute instance
type InstanceState ¶
type InstanceState string
An InstanceState is the state an instance can be in. Valid values are the InstanceState… constants defined in this package.
const ( // InstanceStateStarting is the state of an instance that is starting up, // but not yet ready to be connected to. InstanceStateStarting InstanceState = "starting" // InstanceStateRunning is the state of an instance that has finished // starting up, and will remain in this state until being told to terminate. InstanceStateRunning InstanceState = "running" // InstanceStateTerminating is the state of an instance that has been told // to terminate, but is not yet finished doing that. InstanceStateTerminating InstanceState = "terminating" // InstanceStateTerminated is the state of an instance that is done // terminating. InstanceStateTerminated InstanceState = "terminated" )
type InstanceType ¶
type InstanceType string
An InstanceType is the type of instance to start. Valid values are the InstanceType… constants defined in this package. The instance type defines things such as the amount of resources available.
const ( // InstanceTypeStandard is the default instance type. InstanceTypeStandard InstanceType = "standard" // InstanceTypePremium is an instance type with more resources available // than the standard instance type. InstanceTypePremium InstanceType = "premium" )
type Provider ¶
type Provider interface { List() ([]Instance, error) Create(id string, attr CreateAttributes) (Instance, error) Get(id string) (Instance, error) Destroy(id string) error }
A Provider implements the methods necessary to manage Instances on a given cloud provider.
func NewGCEProviderFromJSON ¶
NewGCEProviderFromJSON deserializes the given jsonConfig into a GCEProviderConfiguration and creates a GCEProvider from that. Used to register the provider with the registry.
func NewProvider ¶
NewProvider creates a new provider given the alias and provider-specific configuration. The alias must match what is passed to registerProvider by the provider, and the configuration is passed to the provider for parsing.