iaas

package
v0.0.0-...-56aa1ee Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: Apache-2.0 Imports: 24 Imported by: 3

Documentation

Index

Constants

View Source
const (
	Unknown = iota
	AWS
	GCP
)

Variables

View Source
var AWSDBSizes = map[string]string{
	"small":   "db.t2.small",
	"medium":  "db.t2.medium",
	"large":   "db.m4.large",
	"xlarge":  "db.m4.xlarge",
	"2xlarge": "db.m4.2xlarge",
	"4xlarge": "db.m4.4xlarge",
}

AWSDBSizes maps user set size to RDS instance classes

View Source
var GCPDBSizes = map[string]string{
	"small":   "db-g1-small",
	"medium":  "db-custom-2-4096",
	"large":   "db-custom-2-8192",
	"xlarge":  "db-custom-4-16384",
	"2xlarge": "db-custom-8-32768",
	"4xlarge": "db-custom-16-65536",
}

GCPDBSizes maps user set size to GCP specific machine type

Functions

func DeleteVolume

func DeleteVolume(ec2Client IEC2, volumeID *string) error

DeleteVolume deletes an EBS volume with the given ID

Types

type AWSProvider

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

AWSProvider is the concrete implementation of AWS Provider

func (*AWSProvider) Attr

func (a *AWSProvider) Attr(name string) (string, error)

Attr returns an attribute of the provider

func (*AWSProvider) BucketExists

func (client *AWSProvider) BucketExists(name string) (bool, error)

BucketExists checks if the named bucket exists

func (*AWSProvider) CheckForWhitelistedIP

func (a *AWSProvider) CheckForWhitelistedIP(ip, securityGroup string) (bool, error)

CheckForWhitelistedIP checks if the specified IP is whitelisted in the security group

func (*AWSProvider) Choose

func (a *AWSProvider) Choose(c Choice) interface{}

Choose for the consumer the appropriate output based on the provider

func (*AWSProvider) CreateBucket

func (client *AWSProvider) CreateBucket(name string) error

CreateBucket checks if the named bucket exists and creates it if it doesn't

func (*AWSProvider) CreateDatabases

func (a *AWSProvider) CreateDatabases(name, username, password string) error

CreateDatabases creates databases on the server

func (*AWSProvider) DBType

func (a *AWSProvider) DBType(name string) string

DBType gets the correct RDSInstance class

func (*AWSProvider) DeleteFile

func (client *AWSProvider) DeleteFile(bucket, path string) error

DeleteFile deletes a file from S3

func (*AWSProvider) DeleteVMsInDeployment

func (a *AWSProvider) DeleteVMsInDeployment(zone, project, deployment string) error

DeleteVMsInDeployment is a placeholder for a function used with GCP deployments

func (*AWSProvider) DeleteVMsInVPC

func (a *AWSProvider) DeleteVMsInVPC(vpcID string) ([]string, error)

DeleteVMsInVPC deletes all the VMs in the given VPC

func (*AWSProvider) DeleteVersionedBucket

func (client *AWSProvider) DeleteVersionedBucket(name string) error

DeleteVersionedBucket deletes and empties a versioned bucket

func (*AWSProvider) DeleteVolumes

func (a *AWSProvider) DeleteVolumes(volumes []string, deleteVolume func(ec2Client IEC2, volumeID *string) error) error

DeleteVolumes deletes the specified EBS volumes

func (*AWSProvider) EnsureFileExists

func (client *AWSProvider) EnsureFileExists(bucket, path string, defaultContents []byte) ([]byte, bool, error)

EnsureFileExists checks for the named file in S3 and creates it if it doesn't exist Second argument is true if new file was created

func (*AWSProvider) FindLongestMatchingHostedZone

func (a *AWSProvider) FindLongestMatchingHostedZone(subdomain string) (string, string, error)

FindLongestMatchingHostedZone finds the longest hosted zone that matches the given subdomain

func (*AWSProvider) HasFile

func (client *AWSProvider) HasFile(bucket, path string) (bool, error)

HasFile returns true if the specified S3 object exists

func (*AWSProvider) IAAS

func (a *AWSProvider) IAAS() Name

IAAS returns the iaas to operate against

func (*AWSProvider) ListHostedZones

func (a *AWSProvider) ListHostedZones() ([]*route53.HostedZone, error)

ListHostedZones returns a list of hosted zones

func (*AWSProvider) LoadFile

func (client *AWSProvider) LoadFile(bucket, path string) ([]byte, error)

LoadFile loads a file from S3

func (*AWSProvider) Region

func (a *AWSProvider) Region() string

Region returns the region to operate against

func (*AWSProvider) WorkerType

func (a *AWSProvider) WorkerType(w string)

WorkerType is a setter for workerType

func (*AWSProvider) WriteFile

func (client *AWSProvider) WriteFile(bucket, path string, contents []byte) error

WriteFile writes the specified S3 object

func (*AWSProvider) Zone

func (a *AWSProvider) Zone(input string) string

Zone is a placeholder for Zone()

type Choice

type Choice struct {
	AWS interface{}
	GCP interface{}
}

Choice is an interface which can help on the abstraction of provider data by defining any kind of data mapped against the available providers

type Factory

type Factory func(iaasName, region string) (Provider, error)

Factory creates a new IaaS provider, defined for testability

type GCPOption

type GCPOption func(*GCPProvider) error

GCPOption is the signature of the option function

func GCPStorage

func GCPStorage() GCPOption

GCPStorage returns an option function with storage initialised

type GCPProvider

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

GCPProvider is the concrete implementation of GCP Provider

func (*GCPProvider) Attr

func (g *GCPProvider) Attr(key string) (string, error)

Attr returns GCP specific attribute

func (*GCPProvider) BucketExists

func (g *GCPProvider) BucketExists(name string) (bool, error)

BucketExists checks if the named bucket exists

func (*GCPProvider) CheckForWhitelistedIP

func (g *GCPProvider) CheckForWhitelistedIP(ip, firewallName string) (bool, error)

CheckForWhitelistedIP checks if the specified IP is whitelisted in the security group

func (*GCPProvider) Choose

func (g *GCPProvider) Choose(c Choice) interface{}

Choose for the consumer the appropriate output based on the provider

func (*GCPProvider) CreateBucket

func (g *GCPProvider) CreateBucket(name string) error

CreateBucket creates a GCP storage bucket with defaults of the US multi-regional location, and a storage class of Standard Storage

func (*GCPProvider) CreateDatabases

func (g *GCPProvider) CreateDatabases(name, username, password string) error

CreateDatabases creates databases on the server

func (*GCPProvider) DBType

func (g *GCPProvider) DBType(name string) string

DBType gets the correct CloudSQL db tier

func (*GCPProvider) DeleteFile

func (g *GCPProvider) DeleteFile(bucket, path string) error

DeleteFile deletes a file from GCP bucket

func (*GCPProvider) DeleteVMsInDeployment

func (g *GCPProvider) DeleteVMsInDeployment(zone, project, deployment string) error

DeleteVMsInDeployment will delete all vms in a deployment apart from nat instance

func (*GCPProvider) DeleteVMsInVPC

func (g *GCPProvider) DeleteVMsInVPC(vpcID string) ([]string, error)

DeleteVMsInVPC is a placeholder function used with AWS deployments

func (*GCPProvider) DeleteVersionedBucket

func (g *GCPProvider) DeleteVersionedBucket(name string) error

DeleteVersionedBucket deletes a bucket and its content from GCP

func (*GCPProvider) DeleteVolumes

func (g *GCPProvider) DeleteVolumes(volumesToDelete []string, deleteVolume func(ec2Client IEC2, volumeID *string) error) error

DeleteVolumes deletes the specified GCP storage volumes

func (*GCPProvider) EnsureFileExists

func (g *GCPProvider) EnsureFileExists(bucket, path string, defaultContents []byte) ([]byte, bool, error)

EnsureFileExists checks for the named file in GCP storage and creates it if it doesn't exist Second argument is true if new file was created

func (*GCPProvider) FindLongestMatchingHostedZone

func (g *GCPProvider) FindLongestMatchingHostedZone(domain string) (string, string, error)

FindLongestMatchingHostedZone finds the longest hosted zone that matches the given subdomain

func (*GCPProvider) HasFile

func (g *GCPProvider) HasFile(bucket, path string) (bool, error)

HasFile returns true if the specified GCP file exists

func (*GCPProvider) IAAS

func (g *GCPProvider) IAAS() Name

IAAS returns the name of the Provider

func (*GCPProvider) LoadFile

func (g *GCPProvider) LoadFile(bucket, path string) ([]byte, error)

LoadFile loads a file from GCP bucket

func (*GCPProvider) Region

func (g *GCPProvider) Region() string

Region returns the region used by the Provider

func (*GCPProvider) WorkerType

func (g *GCPProvider) WorkerType(w string)

WorkerType is a nil setter for workerType

func (*GCPProvider) WriteFile

func (g *GCPProvider) WriteFile(bucket, path string, contents []byte) error

WriteFile writes the specified file to GCP storage

func (*GCPProvider) Zone

func (g *GCPProvider) Zone(input string) string

Zone returns the zone used by the Provider

type GCPStorageClient

type GCPStorageClient interface {
	Bucket(name string) *storage.BucketHandle
	Buckets(ctx context.Context, projectID string) *storage.BucketIterator
}

GCPStorageClient is the interface with GCP storage client

type IEC2

type IEC2 interface {
	DescribeSecurityGroups(input *ec2.DescribeSecurityGroupsInput) (*ec2.DescribeSecurityGroupsOutput, error)
	DescribeVolumes(input *ec2.DescribeVolumesInput) (*ec2.DescribeVolumesOutput, error)
	DeleteVolume(input *ec2.DeleteVolumeInput) (*ec2.DeleteVolumeOutput, error)
}

IEC2 only implements functions used in the iaas package

type Name

type Name int

func Assosiate

func Assosiate(name string) (Name, error)

func (Name) String

func (n Name) String() string

type Provider

type Provider interface {
	Attr(string) (string, error)
	BucketExists(name string) (bool, error)
	CheckForWhitelistedIP(ip, securityGroup string) (bool, error)
	CreateBucket(name string) error
	CreateDatabases(name, username, password string) error
	DeleteFile(bucket, path string) error
	DeleteVersionedBucket(name string) error
	DeleteVMsInDeployment(zone, project, deployment string) error
	DeleteVMsInVPC(vpcID string) ([]string, error)
	DeleteVolumes(volumesToDelete []string, deleteVolume func(ec2Client IEC2, volumeID *string) error) error
	EnsureFileExists(bucket, path string, defaultContents []byte) ([]byte, bool, error)
	FindLongestMatchingHostedZone(subdomain string) (string, string, error)
	HasFile(bucket, path string) (bool, error)
	DBType(name string) string
	IAAS() Name
	LoadFile(bucket, path string) ([]byte, error)
	Region() string
	WorkerType(string)
	WriteFile(bucket, path string, contents []byte) error
	Zone(string) string
	Choose(Choice) interface{}
}

Provider represents actions taken against AWS

func New

func New(iaasName Name, region string) (Provider, error)

New returns a new IAAS client for a particular IAAS and region

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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