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
- func AccountID(clients Clients) (string, error)
- func IsEmptyAmazonAccountID(err error) bool
- func IsInvalidConfig(err error) bool
- func IsMalformedAmazonAccountID(err error) bool
- func IsTooManyResults(err error) bool
- func IsWrongAmazonAccountIDLength(err error) bool
- func IsWrongType(err error) bool
- func ValidateAccountID(accountID string) error
- func VpcCIDR(clients Clients, vpcID string) (string, error)
- type Adapter
- type BlockDeviceMapping
- type CFClient
- type CFClientMock
- func (c *CFClientMock) CreateStack(*awscloudformation.CreateStackInput) (*awscloudformation.CreateStackOutput, error)
- func (c *CFClientMock) DeleteStack(*awscloudformation.DeleteStackInput) (*awscloudformation.DeleteStackOutput, error)
- func (c *CFClientMock) DescribeStacks(*awscloudformation.DescribeStacksInput) (*awscloudformation.DescribeStacksOutput, error)
- func (c *CFClientMock) UpdateStack(*awscloudformation.UpdateStackInput) (*awscloudformation.UpdateStackOutput, error)
- type Clients
- type CloudFormationMock
- func (c *CloudFormationMock) CreateStack(*awscloudformation.CreateStackInput) (*awscloudformation.CreateStackOutput, error)
- func (c *CloudFormationMock) DeleteStack(*awscloudformation.DeleteStackInput) (*awscloudformation.DeleteStackOutput, error)
- func (c *CloudFormationMock) DescribeStacks(*awscloudformation.DescribeStacksInput) (*awscloudformation.DescribeStacksOutput, error)
- func (c *CloudFormationMock) UpdateStack(*awscloudformation.UpdateStackInput) (*awscloudformation.UpdateStackOutput, error)
- func (c *CloudFormationMock) WaitUntilStackCreateComplete(*awscloudformation.DescribeStacksInput) error
- type Config
- type EC2Client
- type EC2ClientMock
- func (e *EC2ClientMock) DescribeRouteTables(input *ec2.DescribeRouteTablesInput) (*ec2.DescribeRouteTablesOutput, error)
- func (e *EC2ClientMock) DescribeSecurityGroups(input *ec2.DescribeSecurityGroupsInput) (*ec2.DescribeSecurityGroupsOutput, error)
- func (e *EC2ClientMock) DescribeSubnets(input *ec2.DescribeSubnetsInput) (*ec2.DescribeSubnetsOutput, error)
- func (e *EC2ClientMock) DescribeVpcPeeringConnections(*ec2.DescribeVpcPeeringConnectionsInput) (*ec2.DescribeVpcPeeringConnectionsOutput, error)
- func (e *EC2ClientMock) DescribeVpcs(input *ec2.DescribeVpcsInput) (*ec2.DescribeVpcsOutput, error)
- func (e *EC2ClientMock) SetUnexistingRouteTable(value bool)
- type ELBClient
- type ELBClientMock
- type IAMClient
- type IAMClientMock
- type KMSClient
- type KMSClientMock
- type RouteTable
- type SmallCloudconfigConfig
Constants ¶
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 IsEmptyAmazonAccountID ¶
IsEmptyAmazonAccountID asserts emptyAmazonAccountIDError.
func IsInvalidConfig ¶
IsInvalidConfig asserts invalidConfigError.
func IsMalformedAmazonAccountID ¶
IsMalformedAmazonAccountID asserts malformedAmazonAccountIDError.
func IsTooManyResults ¶
IsTooManyResults asserts tooManyResultsError.
func IsWrongAmazonAccountIDLength ¶
IsWrongAmazonAccountIDLength asserts wrongAmazonAccountIDLengthError.
func ValidateAccountID ¶
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 NewHostPost ¶
func NewHostPre ¶
type BlockDeviceMapping ¶
type CFClient ¶
type CFClient interface { CreateStack(*awscloudformation.CreateStackInput) (*awscloudformation.CreateStackOutput, error) DeleteStack(*awscloudformation.DeleteStackInput) (*awscloudformation.DeleteStackOutput, error) DescribeStacks(*awscloudformation.DescribeStacksInput) (*awscloudformation.DescribeStacksOutput, error) UpdateStack(*awscloudformation.UpdateStackInput) (*awscloudformation.UpdateStackOutput, error) WaitUntilStackCreateComplete(*awscloudformation.DescribeStacksInput) error }
CFClient describes the methods required to be implemented by a CloudFormation AWS client.
type CFClientMock ¶
type CFClientMock struct{}
func (*CFClientMock) CreateStack ¶
func (c *CFClientMock) CreateStack(*awscloudformation.CreateStackInput) (*awscloudformation.CreateStackOutput, error)
func (*CFClientMock) DeleteStack ¶
func (c *CFClientMock) DeleteStack(*awscloudformation.DeleteStackInput) (*awscloudformation.DeleteStackOutput, error)
func (*CFClientMock) DescribeStacks ¶
func (c *CFClientMock) DescribeStacks(*awscloudformation.DescribeStacksInput) (*awscloudformation.DescribeStacksOutput, error)
func (*CFClientMock) UpdateStack ¶
func (c *CFClientMock) UpdateStack(*awscloudformation.UpdateStackInput) (*awscloudformation.UpdateStackOutput, error)
type CloudFormationMock ¶
type CloudFormationMock struct{}
func (*CloudFormationMock) CreateStack ¶
func (c *CloudFormationMock) CreateStack(*awscloudformation.CreateStackInput) (*awscloudformation.CreateStackOutput, error)
func (*CloudFormationMock) DeleteStack ¶
func (c *CloudFormationMock) DeleteStack(*awscloudformation.DeleteStackInput) (*awscloudformation.DeleteStackOutput, error)
func (*CloudFormationMock) DescribeStacks ¶
func (c *CloudFormationMock) DescribeStacks(*awscloudformation.DescribeStacksInput) (*awscloudformation.DescribeStacksOutput, error)
func (*CloudFormationMock) UpdateStack ¶
func (c *CloudFormationMock) UpdateStack(*awscloudformation.UpdateStackInput) (*awscloudformation.UpdateStackOutput, error)
func (*CloudFormationMock) WaitUntilStackCreateComplete ¶
func (c *CloudFormationMock) WaitUntilStackCreateComplete(*awscloudformation.DescribeStacksInput) error
type EC2Client ¶
type EC2Client interface { DescribeSecurityGroups(*ec2.DescribeSecurityGroupsInput) (*ec2.DescribeSecurityGroupsOutput, error) DescribeSubnets(*ec2.DescribeSubnetsInput) (*ec2.DescribeSubnetsOutput, error) DescribeRouteTables(*ec2.DescribeRouteTablesInput) (*ec2.DescribeRouteTablesOutput, error) DescribeVpcs(*ec2.DescribeVpcsInput) (*ec2.DescribeVpcsOutput, error) DescribeVpcPeeringConnections(*ec2.DescribeVpcPeeringConnectionsInput) (*ec2.DescribeVpcPeeringConnectionsOutput, error) }
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 (e *EC2ClientMock) DescribeSecurityGroups(input *ec2.DescribeSecurityGroupsInput) (*ec2.DescribeSecurityGroupsOutput, error)
func (*EC2ClientMock) DescribeSubnets ¶
func (e *EC2ClientMock) DescribeSubnets(input *ec2.DescribeSubnetsInput) (*ec2.DescribeSubnetsOutput, error)
func (*EC2ClientMock) DescribeVpcPeeringConnections ¶
func (e *EC2ClientMock) DescribeVpcPeeringConnections(*ec2.DescribeVpcPeeringConnectionsInput) (*ec2.DescribeVpcPeeringConnectionsOutput, 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 ¶
func (e *ELBClientMock) DescribeLoadBalancers(input *elb.DescribeLoadBalancersInput) (*elb.DescribeLoadBalancersOutput, error)
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)