common

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2017 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Empty          = ""
	DefaultVersion = "1.0.0-local"
)

Constants used by common package

View Source
const (
	// StackStatusCreateInProgress is a StackStatus enum value
	StackStatusCreateInProgress = "CREATE_IN_PROGRESS"

	// StackStatusCreateFailed is a StackStatus enum value
	StackStatusCreateFailed = "CREATE_FAILED"

	// StackStatusCreateComplete is a StackStatus enum value
	StackStatusCreateComplete = "CREATE_COMPLETE"

	// StackStatusRollbackInProgress is a StackStatus enum value
	StackStatusRollbackInProgress = "ROLLBACK_IN_PROGRESS"

	// StackStatusRollbackFailed is a StackStatus enum value
	StackStatusRollbackFailed = "ROLLBACK_FAILED"

	// StackStatusRollbackComplete is a StackStatus enum value
	StackStatusRollbackComplete = "ROLLBACK_COMPLETE"

	// StackStatusDeleteInProgress is a StackStatus enum value
	StackStatusDeleteInProgress = "DELETE_IN_PROGRESS"

	// StackStatusDeleteFailed is a StackStatus enum value
	StackStatusDeleteFailed = "DELETE_FAILED"

	// StackStatusDeleteComplete is a StackStatus enum value
	StackStatusDeleteComplete = "DELETE_COMPLETE"

	// StackStatusUpdateInProgress is a StackStatus enum value
	StackStatusUpdateInProgress = "UPDATE_IN_PROGRESS"

	// StackStatusUpdateCompleteCleanupInProgress is a StackStatus enum value
	StackStatusUpdateCompleteCleanupInProgress = "UPDATE_COMPLETE_CLEANUP_IN_PROGRESS"

	// StackStatusUpdateComplete is a StackStatus enum value
	StackStatusUpdateComplete = "UPDATE_COMPLETE"

	// StackStatusUpdateRollbackInProgress is a StackStatus enum value
	StackStatusUpdateRollbackInProgress = "UPDATE_ROLLBACK_IN_PROGRESS"

	// StackStatusUpdateRollbackFailed is a StackStatus enum value
	StackStatusUpdateRollbackFailed = "UPDATE_ROLLBACK_FAILED"

	// StackStatusUpdateRollbackCompleteCleanupInProgress is a StackStatus enum value
	StackStatusUpdateRollbackCompleteCleanupInProgress = "UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS"

	// StackStatusUpdateRollbackComplete is a StackStatus enum value
	StackStatusUpdateRollbackComplete = "UPDATE_ROLLBACK_COMPLETE"

	// StackStatusReviewInProgress is a StackStatus enum value
	StackStatusReviewInProgress = "REVIEW_IN_PROGRESS"
)
View Source
const (
	StackTypeVpc          StackType = "vpc"
	StackTypeTarget                 = "target"
	StackTypeIam                    = "iam"
	StackTypeEnv                    = "environment"
	StackTypeLoadBalancer           = "loadbalancer"
	StackTypeConsul                 = "consul"
	StackTypeRepo                   = "repo"
	StackTypeApp                    = "app"
	StackTypeService                = "service"
	StackTypePipeline               = "pipeline"
	StackTypeDatabase               = "database"
	StackTypeBucket                 = "bucket"
)

List of valid stack types

Variables

This section is empty.

Functions

func BoolValue added in v0.2.1

func BoolValue(v *bool) bool

BoolValue returns the value of the bool pointer passed in or false if the pointer is nil.

func CreateStackName

func CreateStackName(namespace string, stackType StackType, names ...string) string

CreateStackName will create a name for a stack

func GetStackOverrides added in v0.1.8

func GetStackOverrides(stackName string) interface{}

GetStackOverrides will get the overrides from the config

func GetVersion

func GetVersion() string

GetVersion returns the current version of the app

func Int64Value added in v0.2.1

func Int64Value(v *int64) int64

Int64Value returns the value of the int64 pointer passed in or 0 if the pointer is nil.

func MapApply added in v0.1.8

func MapApply(dest, src interface{})

MapApply recursively applies map values from source to destination

func SetVersion added in v0.1.3

func SetVersion(v string)

SetVersion returns the current version of the app

func SetupLogging

func SetupLogging(verbosity int)

SetupLogging - verbosity 0=error, 1=info, 2=debug

func StringValue added in v0.2.1

func StringValue(v *string) string

StringValue returns the value of the string pointer passed in or "" if the pointer is nil.

func TimeValue added in v0.2.1

func TimeValue(v *time.Time) time.Time

TimeValue returns the value of the time.Time pointer passed in or time.Time{} if the pointer is nil.

Types

type ArtifactCreator added in v0.2.1

type ArtifactCreator interface {
	CreateArtifact(body io.ReadSeeker, destURI string) error
}

ArtifactCreator for getting cluster instances

type ArtifactManager added in v0.2.1

type ArtifactManager interface {
	ArtifactCreator
}

ArtifactManager composite of all artifact capabilities

type ArtifactProvider added in v0.2.1

type ArtifactProvider string

ArtifactProvider describes supported artifact strategies

const (
	ArtifactProviderEcr ArtifactProvider = "ecr"
	ArtifactProviderS3                   = "s3"
)

List of valid artifact providers

type ClusterInstanceLister

type ClusterInstanceLister interface {
	ListInstances(clusterName string) ([]ContainerInstance, error)
}

ClusterInstanceLister for getting cluster instances

type ClusterManager

type ClusterManager interface {
	ClusterInstanceLister
	RepositoryAuthenticator
}

ClusterManager composite of all cluster capabilities

type Config

type Config struct {
	Namespace    string        `yaml:"namespace,omitempty"`
	Environments []Environment `yaml:"environments,omitempty"`
	Service      Service       `yaml:"service,omitempty"`
	Basedir      string        `yaml:"-"`
	RelMuFile    string        `yaml:"-"`
	Repo         struct {
		Name     string
		Slug     string
		Revision string
		Branch   string
		Provider string
	} `yaml:"-"`
	Templates  map[string]interface{} `yaml:"templates,omitempty"`
	DisableIAM bool                   `yaml:"disableIAM,omitempty"`
	Roles      struct {
		CloudFormation string `yaml:"cloudFormation,omitempty"`
	} `yaml:"roles,omitempty"`
}

Config defines the structure of the yml file for the mu config

type Container added in v0.1.13

type Container struct {
	Name     string
	Instance string
}

Container describes container details

type ContainerInstance added in v0.2.1

type ContainerInstance *ecs.ContainerInstance

ContainerInstance represents the ECS container instance

type Context

type Context struct {
	Config               Config
	StackManager         StackManager
	ClusterManager       ClusterManager
	InstanceManager      InstanceManager
	ElbManager           ElbManager
	RdsManager           RdsManager
	ParamManager         ParamManager
	LocalPipelineManager PipelineManager // instance that ignores region/profile/role
	PipelineManager      PipelineManager
	LogsManager          LogsManager
	DockerManager        DockerManager
	DockerOut            io.Writer
	TaskManager          TaskManager
	ArtifactManager      ArtifactManager
	RolesetManager       RolesetManager
}

Context defines the context object passed around

func NewContext

func NewContext() *Context

NewContext create a new context object

func (*Context) InitializeConfig added in v0.1.7

func (ctx *Context) InitializeConfig(configReader io.Reader) error

InitializeConfig loads config object

func (*Context) InitializeConfigFromFile added in v0.1.7

func (ctx *Context) InitializeConfigFromFile(muFile string) error

InitializeConfigFromFile loads config from file

func (*Context) InitializeContext added in v0.1.7

func (ctx *Context) InitializeContext() error

InitializeContext loads manager objects

type Database added in v0.1.12

type Database struct {
	Name              string                 `yaml:"name,omitempty"`
	Tags              map[string]interface{} `yaml:"tags,omitempty"`
	InstanceClass     string                 `yaml:"instanceClass,omitempty"`
	Engine            string                 `yaml:"engine,omitempty"`
	IamAuthentication bool                   `yaml:"iamAuthentication,omitempty"`
	MasterUsername    string                 `yaml:"masterUsername,omitempty"`
	AllocatedStorage  string                 `yaml:"allocatedStorage,omitempty"`
}

Database definition

type DockerImageBuilder added in v0.1.3

type DockerImageBuilder interface {
	ImageBuild(contextDir string, relDockerfile string, tags []string, dockerOut io.Writer) error
}

DockerImageBuilder for creating docker images

type DockerImagePusher added in v0.1.3

type DockerImagePusher interface {
	ImagePush(image string, registryAuth string, dockerOut io.Writer) error
}

DockerImagePusher for pushing docker images

type DockerManager added in v0.1.3

type DockerManager interface {
	DockerImageBuilder
	DockerImagePusher
}

DockerManager composite of all cluster capabilities

type ECSRunTaskResult added in v0.1.13

type ECSRunTaskResult *ecs.RunTaskOutput

ECSRunTaskResult describes the output result from ECS call to RunTask

type ElbManager added in v0.1.7

type ElbManager interface {
	ElbRuleLister
}

ElbManager composite of all cluster capabilities

type ElbRule added in v0.2.1

type ElbRule *elbv2.Rule

ElbRule for the rules in ELB listeners

type ElbRuleLister added in v0.1.7

type ElbRuleLister interface {
	ListRules(listenerArn string) ([]ElbRule, error)
}

ElbRuleLister for getting cluster instances

type EnvProvider added in v0.2.1

type EnvProvider string

EnvProvider describes supported environment strategies

const (
	EnvProviderEcs EnvProvider = "ecs"
	EnvProviderEc2             = "ec2"
)

List of valid environment strategies

type Environment

type Environment struct {
	Name         string                 `yaml:"name,omitempty"`
	Provider     EnvProvider            `yaml:"provider,omitempty"`
	Tags         map[string]interface{} `yaml:"tags,omitempty"`
	Loadbalancer struct {
		HostedZone  string `yaml:"hostedzone,omitempty"`
		Name        string `yaml:"name,omitempty"`
		Certificate string `yaml:"certificate,omitempty"`
		Internal    bool   `yaml:"internal,omitempty"`
	} `yaml:"loadbalancer,omitempty"`
	Cluster struct {
		InstanceType      string `yaml:"instanceType,omitempty"`
		ImageID           string `yaml:"imageId,omitempty"`
		InstanceTenancy   string `yaml:"instanceTenancy,omitempty"`
		DesiredCapacity   int    `yaml:"desiredCapacity,omitempty"`
		MaxSize           int    `yaml:"maxSize,omitempty"`
		KeyName           string `yaml:"keyName,omitempty"`
		SSHAllow          string `yaml:"sshAllow,omitempty"`
		ScaleOutThreshold int    `yaml:"scaleOutThreshold,omitempty"`
		ScaleInThreshold  int    `yaml:"scaleInThreshold,omitempty"`
		HTTPProxy         string `yaml:"httpProxy,omitempty"`
	} `yaml:"cluster,omitempty"`
	Discovery struct {
		Provider      string            `yaml:"provider,omitempty"`
		Configuration map[string]string `yaml:"configuration,omitempty"`
	} `yaml:"discovery,omitempty"`
	VpcTarget struct {
		VpcID             string   `yaml:"vpcId,omitempty"`
		InstanceSubnetIds []string `yaml:"instanceSubnetIds,omitempty"`
		ElbSubnetIds      []string `yaml:"elbSubnetIds,omitempty"`
	} `yaml:"vpcTarget,omitempty"`
	Roles struct {
		EcsInstance      string `yaml:"ecsInstance,omitempty"`
		ConsulClientTask string `yaml:"consulClientTask,omitempty"`
		ConsulInstance   string `yaml:"consulInstance,omitempty"`
		ConsulServerTask string `yaml:"consulServerTask,omitempty"`
	} `yaml:"roles,omitempty"`
}

Environment defines the structure of the yml file for an environment

type GitInfo added in v0.1.10

type GitInfo struct {
	Provider string
	Revision string
	RepoName string
	Slug     string
}

GitInfo represents pertinent git information

type ImageFinder

type ImageFinder interface {
	FindLatestImageID(namePattern string) (string, error)
}

ImageFinder for finding latest image

type Instance added in v0.2.1

type Instance *ec2.Instance

Instance represents and EC2 instance

type InstanceLister added in v0.2.1

type InstanceLister interface {
	ListInstances(instanceIds ...string) ([]Instance, error)
}

InstanceLister for getting instances

type InstanceManager added in v0.2.1

type InstanceManager interface {
	InstanceLister
}

InstanceManager composite of all instance capabilities

type JSONOutput added in v0.1.13

type JSONOutput struct {
	Values [1]struct {
		Key   string `json:"key"`
		Value string `json:"value"`
	} `json:"values"`
}

JSONOutput common json definition

type LogsManager added in v0.1.10

type LogsManager interface {
	LogsViewer
}

LogsManager composite of all logs capabilities

type LogsViewer added in v0.1.10

type LogsViewer interface {
	ViewLogs(logGroup string, searchDuration time.Duration, follow bool, filter string, callback func(string, string, int64)) error
}

LogsViewer for viewing cloudwatch logs

type ParamGetter added in v0.1.12

type ParamGetter interface {
	GetParam(name string) (string, error)
}

ParamGetter for getting parameters

type ParamManager added in v0.1.12

type ParamManager interface {
	ParamGetter
	ParamSetter
}

ParamManager composite of all param capabilities

type ParamSetter added in v0.1.12

type ParamSetter interface {
	SetParam(name string, value string) error
}

ParamSetter for setting parameters

type Pipeline added in v0.1.5

type Pipeline struct {
	Tags   map[string]interface{} `yaml:"tags,omitempty"`
	Source struct {
		Provider string `yaml:"provider,omitempty"`
		Repo     string `yaml:"repo,omitempty"`
		Branch   string `yaml:"branch,omitempty"`
	} `yaml:"source,omitempty"`
	Build struct {
		Disabled    bool   `yaml:"disabled,omitempty"`
		Type        string `yaml:"type,omitempty"`
		ComputeType string `yaml:"computeType,omitempty"`
		Image       string `yaml:"image,omitempty"`
	} `yaml:"build,omitempty"`
	Acceptance struct {
		Disabled    bool   `yaml:"disabled,omitempty"`
		Environment string `yaml:"environment,omitempty"`
		Type        string `yaml:"type,omitempty"`
		ComputeType string `yaml:"computeType,omitempty"`
		Image       string `yaml:"image,omitempty"`
		Roles       struct {
			CodeBuild string `yaml:"codeBuild,omitempty"`
			Mu        string `yaml:"mu,omitempty"`
		} `yaml:"roles,omitempty"`
	} `yaml:"acceptance,omitempty"`
	Production struct {
		Disabled    bool   `yaml:"disabled,omitempty"`
		Environment string `yaml:"environment,omitempty"`
		Roles       struct {
			CodeBuild string `yaml:"codeBuild,omitempty"`
			Mu        string `yaml:"mu,omitempty"`
		} `yaml:"roles,omitempty"`
	} `yaml:"production,omitempty"`
	MuBaseurl string `yaml:"muBaseurl,omitempty"`
	MuVersion string `yaml:"muVersion,omitempty"`
	Roles     struct {
		Pipeline string `yaml:"pipeline,omitempty"`
		Build    string `yaml:"build,omitempty"`
	} `yaml:"roles,omitempty"`
}

Pipeline definition

type PipelineGitInfoGetter added in v0.1.10

type PipelineGitInfoGetter interface {
	GetGitInfo(pipelineName string) (GitInfo, error)
}

PipelineGitInfoGetter for getting the git revision

type PipelineManager added in v0.1.5

type PipelineManager interface {
	PipelineStateLister
	PipelineGitInfoGetter
}

PipelineManager composite of all cluster capabilities

type PipelineStageState added in v0.2.1

type PipelineStageState *codepipeline.StageState

PipelineStageState a representation of the state of a stage in the pipeline

type PipelineStateLister added in v0.1.5

type PipelineStateLister interface {
	ListState(pipelineName string) ([]PipelineStageState, error)
}

PipelineStateLister for getting cluster instances

type RdsIamAuthenticationSetter added in v0.1.12

type RdsIamAuthenticationSetter interface {
	SetIamAuthentication(dbInstanceIdentifier string, enabled bool, dbEngine string) error
}

RdsIamAuthenticationSetter for getting db instances

type RdsManager added in v0.1.12

type RdsManager interface {
	RdsIamAuthenticationSetter
}

RdsManager composite of all cluster capabilities

type RepositoryAuthenticator added in v0.1.3

type RepositoryAuthenticator interface {
	AuthenticateRepository(repoURL string) (string, error)
}

RepositoryAuthenticator auths for a repo

type Roleset added in v1.0.1

type Roleset map[string]string

Roleset is a map of Role ARNs keyed by role type

type RolesetDeleter added in v1.0.1

type RolesetDeleter interface {
	DeleteCommonRoleset() error
	DeleteEnvironmentRoleset(environmentName string) error
	DeleteServiceRoleset(environmentName string, serviceName string) error
	DeletePipelineRoleset(serviceName string) error
}

RolesetDeleter for deleting a roleset

type RolesetGetter added in v1.0.1

type RolesetGetter interface {
	GetCommonRoleset() (Roleset, error)
	GetEnvironmentRoleset(environmentName string) (Roleset, error)
	GetServiceRoleset(environmentName string, serviceName string) (Roleset, error)
	GetPipelineRoleset(serviceName string) (Roleset, error)
}

RolesetGetter for getting a roleset

type RolesetManager added in v1.0.1

type RolesetManager interface {
	RolesetGetter
	RolesetUpserter
	RolesetDeleter
}

RolesetManager composite of all roleset capabilities

type RolesetUpserter added in v1.0.1

type RolesetUpserter interface {
	UpsertCommonRoleset() error
	UpsertEnvironmentRoleset(environmentName string) error
	UpsertServiceRoleset(environmentName string, serviceName string) error
	UpsertPipelineRoleset(serviceName string) error
}

RolesetUpserter for managing a roleset

type Service

type Service struct {
	Name            string                 `yaml:"name,omitempty"`
	DesiredCount    int                    `yaml:"desiredCount,omitempty"`
	Dockerfile      string                 `yaml:"dockerfile,omitempty"`
	ImageRepository string                 `yaml:"imageRepository,omitempty"`
	Port            int                    `yaml:"port,omitempty"`
	Protocol        string                 `yaml:"protocol,omitempty"`
	HealthEndpoint  string                 `yaml:"healthEndpoint,omitempty"`
	CPU             int                    `yaml:"cpu,omitempty"`
	Memory          int                    `yaml:"memory,omitempty"`
	Environment     map[string]interface{} `yaml:"environment,omitempty"`
	Tags            map[string]interface{} `yaml:"tags,omitempty"`
	PathPatterns    []string               `yaml:"pathPatterns,omitempty"`
	HostPatterns    []string               `yaml:"hostPatterns,omitempty"`
	Priority        int                    `yaml:"priority,omitempty"`
	Pipeline        Pipeline               `yaml:"pipeline,omitempty"`
	Database        Database               `yaml:"database,omitempty"`
	Roles           struct {
		Ec2Instance string `yaml:"ec2Instance,omitempty"`
		CodeDeploy  string `yaml:"codeDeploy,omitempty"`
		EcsService  string `yaml:"ecsService,omitempty"`
		EcsTask     string `yaml:"ecsTask,omitempty"`
	} `yaml:"roles,omitempty"`
}

Service defines the structure of the yml file for a service

type Stack

type Stack struct {
	ID             string
	Name           string
	Status         string
	StatusReason   string
	LastUpdateTime time.Time
	Tags           map[string]string
	Outputs        map[string]string
	Parameters     map[string]string
}

Stack summary

type StackDeleter

type StackDeleter interface {
	DeleteStack(stackName string) error
}

StackDeleter for deleting stacks

type StackGetter

type StackGetter interface {
	GetStack(stackName string) (*Stack, error)
}

StackGetter for getting stacks

type StackLister

type StackLister interface {
	ListStacks(stackType StackType) ([]*Stack, error)
}

StackLister for listing stacks

type StackManager

StackManager composite of all stack capabilities

type StackType

type StackType string

StackType describes supported stack types

type StackUpserter

type StackUpserter interface {
	UpsertStack(stackName string, templateBodyReader io.Reader, parameters map[string]string, tags map[string]string, roleArn string) error
}

StackUpserter for applying changes to a stack

type StackWaiter

type StackWaiter interface {
	AwaitFinalStatus(stackName string) *Stack
}

StackWaiter for waiting on stack status to be final

type Task added in v0.1.13

type Task struct {
	Name           string
	Environment    string
	Service        string
	TaskDefinition string
	Cluster        string
	Command        []string
	Containers     []Container
}

Task describes task definition

type TaskCommandExecutor added in v0.1.13

type TaskCommandExecutor interface {
	ExecuteCommand(namespace string, task Task) (ECSRunTaskResult, error)
}

TaskCommandExecutor for executing commands against an environment

type TaskContainerLister added in v0.1.13

type TaskContainerLister interface {
	ListTasks(namespace string, environment string, serviceName string) ([]Task, error)
}

TaskContainerLister for listing tasks with containers

type TaskManager added in v0.1.13

type TaskManager interface {
	TaskContainerLister
	TaskStopper
	TaskCommandExecutor
}

TaskManager composite of all task capabilities

type TaskStopper added in v1.0.1

type TaskStopper interface {
	StopTask(namespace string, environment string, task string) error
}

TaskStopper for restarting tasks

Jump to

Keyboard shortcuts

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