models

package
v0.0.0-...-e131cc6 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2019 License: Apache-2.0 Imports: 26 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockAwsClients

func MockAwsClients(release *Release) *mocks.MockClients

MockAwsClients mocks

func MockPrepareRelease

func MockPrepareRelease(release *Release)

MockPrepareRelease mocks

func ValidateELB

func ValidateELB(service serviceIface, lb *elb.LoadBalancer) error

ValidateELB returns

func ValidateIAMProfile

func ValidateIAMProfile(service serviceIface, profile *iam.Profile) error

ValidateIAMProfile returns

func ValidateImage

func ValidateImage(service serviceIface, im *ami.Image) error

ValidateImage returns

func ValidatePrevASG

func ValidatePrevASG(service serviceIface, as *asg.ASG) error

ValidatePrevASG returns

func ValidateSecurityGroup

func ValidateSecurityGroup(service serviceIface, sc *sg.SecurityGroup) error

ValidateSecurityGroup returns

func ValidateSubnet

func ValidateSubnet(service serviceIface, subnet *subnet.Subnet) error

ValidateSubnet returns

func ValidateTargetGroup

func ValidateTargetGroup(service serviceIface, tg *alb.TargetGroup) error

ValidateTargetGroup returns

Types

type AutoScalingConfig

type AutoScalingConfig struct {
	MinSize         *int64    `json:"min_size,omitempty"`
	MaxSize         *int64    `json:"max_size,omitempty"`
	MaxTerminations *int64    `json:"max_terms,omitempty"`
	Spread          *float64  `json:"spread,omitempty"`
	Policies        []*Policy `json:"policies,omitempty"`
}

AutoScalingConfig struct

func (*AutoScalingConfig) DesiredCapacity

func (a *AutoScalingConfig) DesiredCapacity(previousDesiredCapacity *int64) int

DesiredCapacity returns default capacity

func (*AutoScalingConfig) MaxSizeInt

func (a *AutoScalingConfig) MaxSizeInt() int

MaxSizeInt returns max size

func (*AutoScalingConfig) MaxTerminationsInt

func (a *AutoScalingConfig) MaxTerminationsInt() int

MaxTerminationsInt returns maximum instances allowed to terminate

func (*AutoScalingConfig) MinSizeInt

func (a *AutoScalingConfig) MinSizeInt() int

MinSizeInt returns min size

func (*AutoScalingConfig) SetDefaults

func (a *AutoScalingConfig) SetDefaults(serviceID *string) error

SetDefaults assigns values

func (*AutoScalingConfig) TargetCapacity

func (a *AutoScalingConfig) TargetCapacity(previousDesiredCapacity *int64) int

TargetCapacity returns target capacity

func (*AutoScalingConfig) TargetHealthy

func (a *AutoScalingConfig) TargetHealthy(previousDesiredCapacity *int64) int

TargetHealthy returns target healthy

func (*AutoScalingConfig) ValidateAttributes

func (a *AutoScalingConfig) ValidateAttributes() error

ValidateAttributes validates attributes

type HaltError

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

HaltError error

func (*HaltError) Error

func (he *HaltError) Error() string

Error returns error

type HealthReport

type HealthReport struct {
	TargetHealthy  *int `json:"target_healthy,omitempty"`  // Number of instances aimed to to Launch
	TargetLaunched *int `json:"target_launched,omitempty"` // Number of instances aimed to to Launch
	Healthy        *int `json:"healthy,omitempty"`         // Number of instances that are healthy
	Launching      *int `json:"launching,omitempty"`       // Number of instances that have been created
	Terminating    *int `json:"terminating,omitempty"`     // Number of instances that are Terminating
}

HealthReport is built to make log lines like: web: .....|. gray targets, red terminated, yellow unhealthy, green healthy

type LifeCycleHook

type LifeCycleHook struct {
	Transistion      *string `json:"transition,omitempty"`
	SNS              *string `json:"sns,omitempty"`
	Role             *string `json:"role,omitempty"`
	HeartbeatTimeout *int64  `json:"heartbeat_timeout,omitempty"`

	RoleARN               *string `json:"role_arn,omitempty"`
	NotificationTargetARN *string `json:"notification_target_arn,omitempty"`
	Name                  *string `json:"name,omitempty"`
}

LifeCycleHook struct

func (*LifeCycleHook) FetchResources

func (lc *LifeCycleHook) FetchResources(iamc aws.IAMAPI, snsc aws.SNSAPI) error

FetchResources validates resources exist

func (*LifeCycleHook) SetDefaults

func (lc *LifeCycleHook) SetDefaults(region *string, accountID *string, name string)

SetDefaults assigns default values

func (*LifeCycleHook) ToLifecycleHookSpecification

func (lc *LifeCycleHook) ToLifecycleHookSpecification() *autoscaling.LifecycleHookSpecification

ToLifecycleHookSpecification returns Specification

func (*LifeCycleHook) ValidateAttributes

func (lc *LifeCycleHook) ValidateAttributes() error

ValidateAttributes validates attributes

type Policy

type Policy struct {
	Type                 *string  `json:"type,omitempty"`
	ScalingAdjustmentVal *int64   `json:"scaling_adjustment,omitempty"`
	ThresholdVal         *float64 `json:"threshold,omitempty"`
	PeriodVal            *int64   `json:"period,omitempty"`
	EvaluationPeriodsVal *int64   `json:"evaluation_periods,omitempty"`
	CooldownVal          *int64   `json:"cooldown,omitempty"`
	// contains filtered or unexported fields
}

Policy struct

func (*Policy) Cooldown

func (a *Policy) Cooldown() *int64

Cooldown returns cooldown

func (*Policy) Create

func (a *Policy) Create(asgc aws.ASGAPI, cwc aws.CWAPI, asgName *string) error

Create attempts to create alarm and policy

func (*Policy) EvaluationPeriods

func (a *Policy) EvaluationPeriods() *int64

EvaluationPeriods returns eval periods

func (*Policy) Name

func (a *Policy) Name() *string

Name returns name

func (*Policy) Period

func (a *Policy) Period() *int64

Period returns period

func (*Policy) ScalingAdjustment

func (a *Policy) ScalingAdjustment() *int64

ScalingAdjustment returns up or down adjustment

func (*Policy) SetDefaults

func (a *Policy) SetDefaults(serviceID *string) error

SetDefaults assigns default values

func (*Policy) Threshold

func (a *Policy) Threshold() *float64

Threshold returns threshold

func (*Policy) ValidateAttributes

func (a *Policy) ValidateAttributes() error

ValidateAttributes validates attributes

type Release

type Release struct {
	// Useful information from AWS
	AwsAccountID *string `json:"aws_account_id,omitempty"`
	AwsRegion    *string `json:"aws_region,omitempty"`

	UUID      *string `json:"uuid,omitempty"`       // Generated By server
	ReleaseID *string `json:"release_id,omitempty"` // Generated Client

	ProjectName *string `json:"project_name,omitempty"`
	ConfigName  *string `json:"config_name,omitempty"`
	Bucket      *string `json:"bucket,omitempty"` // Bucket with Additional Data in it

	Subnets []*string `json:"subnets,omitempty"`
	Timeout *int      `json:"timeout,omitempty"` // How long should we try and deploy in seconds

	CreatedAt     *time.Time `json:"created_at,omitempty"`
	ReleaseSHA256 string     `json:"release_sha256"` // Not Set By Client

	Success *bool `json:"success,omitempty"`

	Image *string `json:"ami,omitempty"`

	UserData *string `json:"user_data,omitempty"`

	// LifeCycleHooks
	LifeCycleHooks map[string]*LifeCycleHook `json:"lifecycle,omitempty"`

	// Maintain a Log to look at what has happened
	Healthy *bool `json:"healthy,omitempty"`

	// Where the previous Catch Error should be located
	Error *ReleaseError `json:"error,omitempty"`

	// AWS Service is Downloaded
	Services map[string]*Service `json:"services,omitempty"` // Downloaded From S3
}

Release is the Data Structure passed between Client to Deployer

func MockMinimalRelease

func MockMinimalRelease(t *testing.T) *Release

MockMinimalRelease mocks

func MockRelease

func MockRelease(t *testing.T) *Release

MockRelease mocks

func (*Release) CreateResources

func (release *Release) CreateResources(asgc aws.ASGAPI, cwc aws.CWAPI) error

CreateResources returns

func (*Release) FetchResources

func (release *Release) FetchResources(asgc aws.ASGAPI, ec2 aws.EC2API, elbc aws.ELBAPI, albc aws.ALBAPI, iamc aws.IAMAPI, snsc aws.SNSAPI) (map[string]*ServiceResources, error)

FetchResources checks the existence of all Resources references in this release and returns a struct of the resources

func (*Release) GrabLock

func (release *Release) GrabLock(s3Client aws.S3API) (bool, error)

GrabLock tries to grab the lock

func (*Release) Halt

func (release *Release) Halt(s3c aws.S3API) error

Halt returns

func (*Release) HaltPath

func (release *Release) HaltPath() *string

HaltPath returns

func (*Release) IsHalt

func (release *Release) IsHalt(s3c aws.S3API) error

IsHalt will try but no guarantees to work

func (*Release) LockPath

func (release *Release) LockPath() *string

LockPath returns

func (*Release) ReleaseLock

func (release *Release) ReleaseLock(s3Client aws.S3API) error

ReleaseLock tries to release the lock

func (*Release) ReleasePath

func (release *Release) ReleasePath() *string

ReleasePath returns

func (*Release) RemoveHalt

func (release *Release) RemoveHalt(s3c aws.S3API)

RemoveHalt returns

func (*Release) SetDefaultRegionAccount

func (release *Release) SetDefaultRegionAccount(region *string, account *string)

SetDefaultRegionAccount returns

func (*Release) SetDefaults

func (release *Release) SetDefaults()

SetDefaults assigns default values

func (*Release) SetUUID

func (release *Release) SetUUID()

SetUUID returns

func (*Release) SuccessfulTearDown

func (release *Release) SuccessfulTearDown(asgc aws.ASGAPI, cwc aws.CWAPI) error

SuccessfulTearDown returns

func (*Release) UnmarshalJSON

func (release *Release) UnmarshalJSON(data []byte) error

UnmarshalJSON should error if there is something unexpected

func (*Release) UnsuccssfulTearDown

func (release *Release) UnsuccssfulTearDown(asgc aws.ASGAPI, cwc aws.CWAPI) error

UnsuccssfulTearDown deletes the services we were trying to create because :(

func (*Release) UpdateHealthy

func (release *Release) UpdateHealthy(asgc aws.ASGAPI, elbc aws.ELBAPI, albc aws.ALBAPI) error

UpdateHealthy will try set the Healthy attribute First Error is a Halting Error, Second Error is a Retry Error

func (*Release) UpdateWithResources

func (release *Release) UpdateWithResources(resources map[string]*ServiceResources)

UpdateWithResources returns

func (*Release) Validate

func (release *Release) Validate(s3c aws.S3API) error

Validate returns

func (*Release) ValidateAttributes

func (release *Release) ValidateAttributes() error

ValidateAttributes validates attributes

func (*Release) ValidateReleaseSHA

func (release *Release) ValidateReleaseSHA(s3c aws.S3API) error

ValidateReleaseSHA returns

func (*Release) ValidateResources

func (release *Release) ValidateResources(resources map[string]*ServiceResources) error

ValidateResources returns

func (*Release) ValidateServices

func (release *Release) ValidateServices() error

ValidateServices returns

type ReleaseError

type ReleaseError struct {
	Error *string
	Cause *string
}

ReleaseError error

type Service

type Service struct {

	// Generated
	ServiceID   *string `json:"service_id,omitempty"`
	ServiceName *string `json:"service_name,omitempty"`

	// Find these Resources
	ELBs           []*string          `json:"elbs,omitempty"`
	Profile        *string            `json:"profile,omitempty"`
	TargetGroups   []*string          `json:"target_groups,omitempty"`
	SecurityGroups []*string          `json:"security_groups,omitempty"`
	Tags           map[string]*string `json:"tags,omitempty"`

	// Create Resources
	InstanceType *string            `json:"instance_type,omitempty"`
	Autoscaling  *AutoScalingConfig `json:"autoscaling,omitempty"`

	// EBS
	EBSVolumeSize *int64  `json:"ebs_volume_size,omitempty"`
	EBSVolumeType *string `json:"ebs_volume_type,omitempty"`
	EBSDeviceName *string `json:"ebs_device_name,omitempty"`

	// Found Resources
	Resources *ServiceResourceNames `json:"resources,omitempty"`

	// Created Resources
	CreatedASG              *string `json:"created_asg,omitempty"`
	PreviousDesiredCapacity *int64  `json:"previous_desired_capacity,omitempty"`

	// What is Healthy
	HealthReport *HealthReport `json:"healthy_report,omitempty"`
	Healthy      bool
	// contains filtered or unexported fields
}

Service struct

func (*Service) ConfigName

func (service *Service) ConfigName() *string

ConfigName returns config name

func (*Service) CreateResources

func (service *Service) CreateResources(asgc aws.ASGAPI, cwc aws.CWAPI) error

CreateResources creates the ASG and Launch configuration for the service

func (*Service) FetchResources

func (service *Service) FetchResources(ec2 aws.EC2API, elbc aws.ELBAPI, albc aws.ALBAPI, iamc aws.IAMAPI) (*ServiceResources, error)

FetchResources attempts to retrieve all resources

func (*Service) LifeCycleHookSpecs

func (service *Service) LifeCycleHookSpecs() []*autoscaling.LifecycleHookSpecification

LifeCycleHookSpecs returns

func (*Service) LifeCycleHooks

func (service *Service) LifeCycleHooks() map[string]*LifeCycleHook

LifeCycleHooks returns

func (*Service) Name

func (service *Service) Name() *string

Name service name

func (*Service) ProjectName

func (service *Service) ProjectName() *string

ProjectName returns project name

func (*Service) ReleaseID

func (service *Service) ReleaseID() *string

ReleaseID returns release ID

func (*Service) ReleaseUUID

func (service *Service) ReleaseUUID() *string

ReleaseUUID returns release UUID

func (*Service) SetDefaults

func (service *Service) SetDefaults(release *Release, serviceName string)

SetDefaults assigns default values

func (*Service) SubnetIds

func (service *Service) SubnetIds() *string

SubnetIds returns

func (*Service) Subnets

func (service *Service) Subnets() []*string

Subnets returns subnets

func (*Service) UpdateHealthy

func (service *Service) UpdateHealthy(asgc aws.ASGAPI, elbc aws.ELBAPI, albc aws.ALBAPI) error

UpdateHealthy updates the health status of the service This might cause a Halt Error which will force the release to stop

func (*Service) UserData

func (service *Service) UserData() *string

UserData will take the releases template and override

func (*Service) Validate

func (service *Service) Validate() error

Validate validates the service

func (*Service) ValidateAttributes

func (service *Service) ValidateAttributes() error

ValidateAttributes validates attributes

type ServiceResourceNames

type ServiceResourceNames struct {
	Image          *string   `json:"image,omitempty"`
	Profile        *string   `json:"profile_arn,omitempty"`
	PrevASG        *string   `json:"prev_asg_arn,omitempty"`
	SecurityGroups []*string `json:"security_groups,omitempty"`
	ELBs           []*string `json:"elbs,omitempty"`
	TargetGroups   []*string `json:"target_group_arns,omitempty"`
	Subnets        []*string `json:"subnets,omitempty"`
}

ServiceResourceNames struct

type ServiceResources

type ServiceResources struct {
	Image          *ami.Image
	Profile        *iam.Profile
	PrevASG        *asg.ASG
	SecurityGroups []*sg.SecurityGroup
	ELBs           []*elb.LoadBalancer
	TargetGroups   []*alb.TargetGroup
	Subnets        []*subnet.Subnet
}

ServiceResources struct

func (*ServiceResources) ToServiceResourceNames

func (sr *ServiceResources) ToServiceResourceNames() *ServiceResourceNames

ToServiceResourceNames returns

func (*ServiceResources) Validate

func (sr *ServiceResources) Validate(service *Service) error

Validate returns

Jump to

Keyboard shortcuts

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