adapter

package
v7.0.0-fix+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2020 License: Apache-2.0 Imports: 10 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

This section is empty.

Variables

This section is empty.

Functions

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 IsNotFound

func IsNotFound(err error) bool

IsNotFound asserts notFoundError

func IsTooFewResults

func IsTooFewResults(err error) bool

IsTooFewResults asserts tooFewResultsError.

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.

Types

type APIWhitelist

type APIWhitelist struct {
	Private Whitelist
	Public  Whitelist
}

APIWhitelist defines guest cluster k8s public/private api whitelisting.

type Adapter

type Adapter struct {
	Guest GuestAdapter
}

func NewGuest

func NewGuest(cfg Config) (Adapter, error)

type Config

type Config struct {
	APIWhitelist                    APIWhitelist
	AWSRegion                       string
	ControlPlaneAccountID           string
	ControlPlaneNATGatewayAddresses []*ec2.Address
	ControlPlanePeerRoleARN         string
	ControlPlaneVPCID               string
	ControlPlaneVPCCidr             string
	CustomObject                    v1alpha1.Cluster
	EncrypterBackend                string
	GuestAccountID                  string
	InstallationName                string
	PublicRouteTables               string
	Route53Enabled                  bool
	StackState                      StackState
	TenantClusterAccountID          string
	TenantClusterKMSKeyARN          string
	TenantClusterAvailabilityZones  []controllercontext.ContextSpecTenantClusterTCCPAvailabilityZone
}

type Gateway

type Gateway struct {
	AvailabilityZone string
	NATGWName        string
	NATEIPName       string
	PublicSubnetName string
}

type GuestIAMPoliciesAdapter

type GuestIAMPoliciesAdapter struct {
	ClusterID         string
	EC2ServiceDomain  string
	KMSKeyARN         string
	MasterRoleName    string
	MasterPolicyName  string
	MasterProfileName string
	RegionARN         string
	S3Bucket          string
}

func (*GuestIAMPoliciesAdapter) Adapt

func (i *GuestIAMPoliciesAdapter) Adapt(cfg Config) error

type GuestInstanceAdapter

type GuestInstanceAdapter struct {
	Cluster GuestInstanceAdapterCluster
	Image   GuestInstanceAdapterImage
	Master  GuestInstanceAdapterMaster
}

func (*GuestInstanceAdapter) Adapt

func (i *GuestInstanceAdapter) Adapt(config Config) error

type GuestInstanceAdapterCluster

type GuestInstanceAdapterCluster struct {
	ID string
}

type GuestInstanceAdapterImage

type GuestInstanceAdapterImage struct {
	ID string
}

type GuestInstanceAdapterMaster

type GuestInstanceAdapterMaster struct {
	AZ               string
	CloudConfig      string
	EncrypterBackend string
	DockerVolume     GuestInstanceAdapterMasterDockerVolume
	EtcdVolume       GuestInstanceAdapterMasterEtcdVolume
	LogVolume        GuestInstanceAdapterMasterLogVolume
	Instance         GuestInstanceAdapterMasterInstance
	PrivateSubnet    string
}

type GuestInstanceAdapterMasterDockerVolume

type GuestInstanceAdapterMasterDockerVolume struct {
	Name         string
	ResourceName string
}

type GuestInstanceAdapterMasterEtcdVolume

type GuestInstanceAdapterMasterEtcdVolume struct {
	Name string
}

type GuestInstanceAdapterMasterInstance

type GuestInstanceAdapterMasterInstance struct {
	ResourceName string
	Type         string
	Monitoring   bool
}

type GuestInstanceAdapterMasterLogVolume

type GuestInstanceAdapterMasterLogVolume struct {
	Name string
}

type GuestInternetGatewayAdapter

type GuestInternetGatewayAdapter struct {
	ClusterID        string
	InternetGateways []GuestInternetGatewayAdapterInternetGateway
}

func (*GuestInternetGatewayAdapter) Adapt

type GuestInternetGatewayAdapterInternetGateway

type GuestInternetGatewayAdapterInternetGateway struct {
	InternetGatewayRoute string
	RouteTable           string
}

type GuestLoadBalancersAdapter

type GuestLoadBalancersAdapter struct {
	APIElbHealthCheckTarget          string
	APIElbName                       string
	APIInternalElbName               string
	APIElbPortsToOpen                []GuestLoadBalancersAdapterPortPair
	APIElbScheme                     string
	APIInternalElbScheme             string
	APIElbSecurityGroupID            string
	EtcdElbHealthCheckTarget         string
	EtcdElbName                      string
	EtcdElbPortsToOpen               []GuestLoadBalancersAdapterPortPair
	EtcdElbScheme                    string
	EtcdElbSecurityGroupID           string
	ELBHealthCheckHealthyThreshold   int
	ELBHealthCheckInterval           int
	ELBHealthCheckTimeout            int
	ELBHealthCheckUnhealthyThreshold int
	IngressElbHealthCheckTarget      string
	IngressElbName                   string
	IngressElbPortsToOpen            []GuestLoadBalancersAdapterPortPair
	IngressElbScheme                 string
	MasterInstanceResourceName       string
	PublicSubnets                    []string
	PrivateSubnets                   []string
}

func (*GuestLoadBalancersAdapter) Adapt

func (a *GuestLoadBalancersAdapter) Adapt(cfg Config) error

type GuestLoadBalancersAdapterPortPair

type GuestLoadBalancersAdapterPortPair struct {
	// PortELB is the port the ELB should listen on.
	PortELB int
	// PortInstance is the port on the instance the ELB forwards traffic to.
	PortInstance int
}

type GuestNATGatewayAdapter

type GuestNATGatewayAdapter struct {
	Gateways  []Gateway
	NATRoutes []NATRoute
}

func (*GuestNATGatewayAdapter) Adapt

func (a *GuestNATGatewayAdapter) Adapt(cfg Config) error

type GuestOutputsAdapter

type GuestOutputsAdapter struct {
	Master          GuestOutputsAdapterMaster
	OperatorVersion string
	Route53Enabled  bool
}

func (*GuestOutputsAdapter) Adapt

func (a *GuestOutputsAdapter) Adapt(config Config) error

type GuestOutputsAdapterMaster

type GuestOutputsAdapterMaster struct {
	ImageID      string
	Instance     GuestOutputsAdapterMasterInstance
	DockerVolume GuestOutputsAdapterMasterDockerVolume
}

type GuestOutputsAdapterMasterDockerVolume

type GuestOutputsAdapterMasterDockerVolume struct {
	ResourceName string
}

type GuestOutputsAdapterMasterInstance

type GuestOutputsAdapterMasterInstance struct {
	ResourceName string
	Type         string
}

type GuestRecordSetsAdapter

type GuestRecordSetsAdapter struct {
	BaseDomain                 string
	EtcdDomain                 string
	ClusterID                  string
	MasterInstanceResourceName string
	Route53Enabled             bool
	VPCRegion                  string
}

func (*GuestRecordSetsAdapter) Adapt

func (a *GuestRecordSetsAdapter) Adapt(config Config) error

type GuestRouteTablesAdapter

type GuestRouteTablesAdapter struct {
	HostClusterCIDR        string
	PrivateRouteTableNames []RouteTableName
	PublicRouteTableNames  []RouteTableName
}

func (*GuestRouteTablesAdapter) Adapt

func (r *GuestRouteTablesAdapter) Adapt(cfg Config) error

type GuestSecurityGroupsAdapter

type GuestSecurityGroupsAdapter struct {
	APIInternalELBSecurityGroupName  string
	APIInternalELBSecurityGroupRules []securityGroupRule
	APIWhitelistEnabled              bool
	PrivateAPIWhitelistEnabled       bool
	MasterSecurityGroupName          string
	MasterSecurityGroupRules         []securityGroupRule
	IngressSecurityGroupName         string
	IngressSecurityGroupRules        []securityGroupRule
	EtcdELBSecurityGroupName         string
	EtcdELBSecurityGroupRules        []securityGroupRule
}

func (*GuestSecurityGroupsAdapter) Adapt

func (s *GuestSecurityGroupsAdapter) Adapt(cfg Config) error

type GuestSubnetsAdapter

type GuestSubnetsAdapter struct {
	PublicSubnets  []Subnet
	PrivateSubnets []Subnet
}

func (*GuestSubnetsAdapter) Adapt

func (s *GuestSubnetsAdapter) Adapt(cfg Config) error

type GuestVPCAdapter

type GuestVPCAdapter struct {
	CidrBlock        string
	ClusterID        string
	InstallationName string
	HostAccountID    string
	PeerVPCID        string
	PeerRoleArn      string
	Region           string
	RegionARN        string
	RouteTableNames  []RouteTableName
}

func (*GuestVPCAdapter) Adapt

func (v *GuestVPCAdapter) Adapt(cfg Config) error

type Hydrater

type Hydrater func(config Config) error

type NATRoute

type NATRoute struct {
	NATGWName             string
	NATRouteName          string
	PrivateRouteTableName string
}

type RouteTableAssociation

type RouteTableAssociation struct {
	Name           string
	RouteTableName string
	SubnetName     string
}

type RouteTableName

type RouteTableName struct {
	AvailabilityZone    string
	ResourceName        string
	VPCPeeringRouteName string
}

type SmallCloudconfigConfig

type SmallCloudconfigConfig struct {
	S3URL string
}

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

type StackState

type StackState struct {
	Name string

	DockerVolumeResourceName   string
	MasterImageID              string
	MasterInstanceType         string
	MasterInstanceResourceName string
	MasterInstanceMonitoring   bool

	OperatorVersion string
}

TODO we copy this because of a circular import issue with the cloudformation resource. The way how the resource works with the adapter and how infromation is passed has to be reworked at some point. Just hacking this now to keep going and to keep the changes as minimal as possible.

type Subnet

type Subnet struct {
	AvailabilityZone      string
	CIDR                  string
	Name                  string
	MapPublicIPOnLaunch   bool
	RouteTableAssociation RouteTableAssociation
}

type Whitelist

type Whitelist struct {
	Enabled    bool
	SubnetList string
}

Whitelist represents the structure required for defining whitelisting for resource security group

Jump to

Keyboard shortcuts

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