Documentation ¶
Index ¶
- func LoadFixture(pth string) []byte
- func Name(resource, detail string, i int) string
- type Box
- type BoxName
- type CloudProvider
- type IP
- type IPType
- type Inventory
- type MockCloudProvider
- func (m *MockCloudProvider) CreateStaticIP(ctx context.Context, name string, typ IPType) (*IP, error)
- func (m *MockCloudProvider) CreateVM(ctx context.Context, vm *VM) error
- func (m *MockCloudProvider) Delete(ctx context.Context, name string) error
- func (m *MockCloudProvider) GetAll(ctx context.Context) ([]*VM, error)
- func (m *MockCloudProvider) GetStaticIPs(context.Context) ([]*IP, error)
- type Plan
- type Service
- type Terrafirma
- type VM
- type VMTemplate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadFixture ¶
LoadFixture from testdata, outputting the bytes, or panic if anything fails. This should only be used in tests. The path should be relative to the testdata directory.
Types ¶
type Box ¶
type Box struct { Name BoxName `json:"name"` CPU int `json:"cpu"` RAM datasize `json:"ram"` Disk datasize `json:"disk"` Image string `json:"image"` // AllowHTTP will disable any cloud-based firewall on ports 80 and 443. // This is useful for reverse-proxy boxes that need to be exposed to // the public internet. AllowHTTP bool `json:"allowHTTP,omitempty"` }
type CloudProvider ¶
type CloudProvider interface { // GetAll VMs on the cloud provider. GetAll(context.Context) ([]*VM, error) // Delete the given VM. The implementation should shutdown the VM // properly prior to delete and hang until the box is completely // deleted. Delete(ctx context.Context, name string) error // CreateVM must hang until boot completes. CreateVM(context.Context, *VM) error // GetStaticIPs to be used by newly created VMs. GetStaticIPs(context.Context) ([]*IP, error) // CreateStaticIP reporting its address and type. CreateStaticIP(_ context.Context, name string, _ IPType) (*IP, error) }
type MockCloudProvider ¶
type MockCloudProvider struct {
// contains filtered or unexported fields
}
MockCloudProvider implements the CloudProvider interface for simplified testing.
func (*MockCloudProvider) CreateStaticIP ¶
func (*MockCloudProvider) CreateVM ¶
func (m *MockCloudProvider) CreateVM(ctx context.Context, vm *VM) error
func (*MockCloudProvider) Delete ¶
func (m *MockCloudProvider) Delete(ctx context.Context, name string) error
func (*MockCloudProvider) GetAll ¶
func (m *MockCloudProvider) GetAll(ctx context.Context) ([]*VM, error)
func (*MockCloudProvider) GetStaticIPs ¶
func (m *MockCloudProvider) GetStaticIPs(context.Context) ([]*IP, error)
type Plan ¶
type Plan struct { Create []*VMTemplate `json:"create"` Destroy []*VM `json:"destroy"` }
type Terrafirma ¶
type Terrafirma struct { CloudProvider // contains filtered or unexported fields }
func New ¶
func New( provider CloudProvider, timeout time.Duration, ) *Terrafirma
func (*Terrafirma) CreateAll ¶
func (t *Terrafirma) CreateAll(boxes map[BoxName]*Box, p *Plan) error
func (*Terrafirma) DestroyAll ¶
func (t *Terrafirma) DestroyAll(p *Plan) error
func (*Terrafirma) Inventory ¶
func (t *Terrafirma) Inventory() ([]*VM, error)
Inventory outputs a full inventory from the current state. This may be repeated after Create and Destroy to get the state at any moment.
type VM ¶
type VM struct { // Name of the VM. Name string `json:"name"` // CPU is the number of cores. CPU int `json:"cpu"` // Mem provisioned to the VM. Mem int `json:"mem"` // Disk size in GB. Disk int `json:"disk"` // Image installed on the disk. Image string `json:"image,omitempty"` // Tags on the box applied during creation to indicate the services to // be deployed. Tags []string `json:"-"` // IPs assigned to the box. IPs []*IP `json:"ips,omitempty"` // AllowHTTP will disable any cloud-based firewall on ports 80 and 443. // This is useful for reverse-proxy boxes that need to be exposed to // the public internet. AllowHTTP bool `json:"allowHTTP,omitempty"` }
type VMTemplate ¶
type VMTemplate struct { // VMName to be assigned in the cloud provider. VMName string `json:"vm_name"` // BoxName is the name of the box which should be used when creating // the VM, which defines the image, CPU, RAM, and Disk. BoxName BoxName `json:"box_name"` // Tags indicate the services to be deployed on a VM. Tags []string `json:"tags"` // IPs contains public and private IPs that will be assinged to the VM. IPs []*IP `json:"ips"` }
VMTemplate is a VM that is yet to be created.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.