adapter

package
v0.0.0-...-17b5b8b Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package adapter contains the required logic for creating data structures used for feeding CloudFormation templates.

It follows the adapter pattern https://en.wikipedia.org/wiki/Adapter_pattern in the sense that it has the knowledge to transform a aws custom object into a data structure easily interpolable into the templates without any additional view logic.

There's a base template in `service/templates/cloudformation/guest/main.yaml` which defines the basic structure and includes the rest of templates that form the stack as nested templates. Those subtemplates should use a `define` action with the name that will be used to refer to them from the main template, as explained here https://golang.org/pkg/text/template/#hdr-Nested_template_definitions

Each adapter is related to one of these nested templates. It includes the data structure with all the values needed to interpolate in the related template and the logic required to obtain them, this logic is packed into functions called `hydraters`.

When extending the stack we will just need to: * Add the template file in `service/template/cloudformation/guest` and modify `service/template/cloudformation/main.yaml` to include the new template. * Add the adapter logic file in `service/resource/cloudformation/adapter` with the type definition and the hydrater function to fill the fields (like asg.go or launch_configuration.go). * Add the new type to the Adapter type in `service/resource/cloudformation/adapter/adapter.go` and include the hydrater function in the `hydraters` slice.

Index

Constants

View Source
const (

	// RootDirElement marks the directory that should be taken as root when evaluating
	// template's relative paths.
	RootDirElement = "aws-operator"
)

Variables

This section is empty.

Functions

func AccountID

func AccountID(clients Clients) (string, error)

func IsEmptyAmazonAccountID

func IsEmptyAmazonAccountID(err error) bool

IsEmptyAmazonAccountID asserts emptyAmazonAccountIDError.

func IsInvalidConfig

func IsInvalidConfig(err error) bool

IsInvalidConfig asserts invalidConfigError.

func IsMalformedAmazonAccountID

func IsMalformedAmazonAccountID(err error) bool

IsMalformedAmazonAccountID asserts malformedAmazonAccountIDError.

func IsTooManyResults

func IsTooManyResults(err error) bool

IsTooManyResults asserts tooManyResultsError.

func IsWrongAmazonAccountIDLength

func IsWrongAmazonAccountIDLength(err error) bool

IsWrongAmazonAccountIDLength asserts wrongAmazonAccountIDLengthError.

func IsWrongType

func IsWrongType(err error) bool

IsWrongType asserts wrongTypeError.

func ValidateAccountID

func ValidateAccountID(accountID string) error

func VpcCIDR

func VpcCIDR(clients Clients, vpcID string) (string, error)

Types

type Adapter

type Adapter struct {
	ASGType          string
	AvailabilityZone string
	ClusterID        string
	MasterImageID    string
	WorkerImageID    string

	LifecycleHooks *lifecycleHooksAdapter
	Outputs        *outputsAdapter
	// contains filtered or unexported fields
}

func NewGuest

func NewGuest(cfg Config) (Adapter, error)

func NewHostPost

func NewHostPost(cfg Config) (Adapter, error)

func NewHostPre

func NewHostPre(cfg Config) (Adapter, error)

type BlockDeviceMapping

type BlockDeviceMapping struct {
	DeleteOnTermination bool
	DeviceName          string
	VolumeSize          int
	VolumeType          string
}

type CFClient

CFClient describes the methods required to be implemented by a CloudFormation AWS client.

type Clients

type Clients struct {
	CloudFormation CFClient
	EC2            EC2Client
	IAM            IAMClient
	KMS            KMSClient
	ELB            ELBClient
}

type CloudFormationMock

type CloudFormationMock struct{}

func (*CloudFormationMock) WaitUntilStackCreateComplete

func (c *CloudFormationMock) WaitUntilStackCreateComplete(*awscloudformation.DescribeStacksInput) error

type Config

type Config struct {
	CustomObject     v1alpha1.AWSConfig
	Clients          Clients
	HostClients      Clients
	InstallationName string
	HostAccountID    string
	GuestAccountID   string
}

type EC2Client

EC2Client describes the methods required to be implemented by a EC2 AWS client.

type EC2ClientMock

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

func (*EC2ClientMock) DescribeRouteTables

func (e *EC2ClientMock) DescribeRouteTables(input *ec2.DescribeRouteTablesInput) (*ec2.DescribeRouteTablesOutput, error)

func (*EC2ClientMock) DescribeSecurityGroups

func (*EC2ClientMock) DescribeSubnets

func (e *EC2ClientMock) DescribeSubnets(input *ec2.DescribeSubnetsInput) (*ec2.DescribeSubnetsOutput, error)

func (*EC2ClientMock) DescribeVpcs

func (e *EC2ClientMock) DescribeVpcs(input *ec2.DescribeVpcsInput) (*ec2.DescribeVpcsOutput, error)

func (*EC2ClientMock) SetUnexistingRouteTable

func (e *EC2ClientMock) SetUnexistingRouteTable(value bool)

type ELBClient

type ELBClient interface {
	DescribeLoadBalancers(*elb.DescribeLoadBalancersInput) (*elb.DescribeLoadBalancersOutput, error)
}

ELBClient describes the methods required to be implemented by a ELB AWS client.

type ELBClientMock

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

func (*ELBClientMock) DescribeLoadBalancers

type IAMClient

type IAMClient interface {
	GetUser(*iam.GetUserInput) (*iam.GetUserOutput, error)
	GetRole(*iam.GetRoleInput) (*iam.GetRoleOutput, error)
}

IAMClient describes the methods required to be implemented by a IAM AWS client.

type IAMClientMock

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

func (*IAMClientMock) GetRole

func (i *IAMClientMock) GetRole(input *iam.GetRoleInput) (*iam.GetRoleOutput, error)

func (*IAMClientMock) GetUser

func (i *IAMClientMock) GetUser(input *iam.GetUserInput) (*iam.GetUserOutput, error)

type KMSClient

type KMSClient interface {
	DescribeKey(*kms.DescribeKeyInput) (*kms.DescribeKeyOutput, error)
}

KMSClient describes the methods required to be implemented by a KMS AWS client.

type KMSClientMock

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

func (*KMSClientMock) DescribeKey

func (k *KMSClientMock) DescribeKey(input *kms.DescribeKeyInput) (*kms.DescribeKeyOutput, error)

type RouteTable

type RouteTable struct {
	Name             string
	RouteTableID     string
	CidrBlock        string
	PeerConnectionID string
}

type SmallCloudconfigConfig

type SmallCloudconfigConfig struct {
	MachineType        string
	Region             string
	S3URI              string
	CloudConfigVersion string
}

SmallCloudconfigConfig represents the data structure required for executing the small cloudconfig template.

Jump to

Keyboard shortcuts

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