empire

package module
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2016 License: BSD-2-Clause Imports: 32 Imported by: 0

README

Empire

Install

readthedocs badge Circle CI

Empire is a control layer on top of Amazon EC2 Container Service (ECS) that provides a Heroku like workflow. It conforms to a subset of the Heroku Platform API, which means you can use the same tools and processes that you use with Heroku, but with all the power of EC2 and Docker.

Empire is targeted at small to medium sized startups that are running a large number of microservices and need more flexibility than what Heroku provides. You can read the original blog post about why we built empire on the Remind engineering blog.

Quickstart

To use Empire, you'll need to have an ECS cluster running. See the quickstart guide for more information.

Architecture

Empire aims to make it trivially easy to deploy a container based microservices architecture, without all of the complexities of managing systems like Mesos or Kubernetes. ECS takes care of much of that work, but Empire attempts to enhance the interface to ECS for deploying and maintaining applications, allowing you to deploy Docker images as easily as:

$ emp deploy remind101/acme-inc:latest
Heroku API compatibility

Empire supports a subset of the Heroku Platform API, which means any tool that uses the Heroku API can probably be used with Empire, if the endpoint is supported.

As an example, you can use the hk CLI with Empire like this:

$ HEROKU_API_URL=<empire_url> hk ...

However, the best user experience will be by using the emp command, which is a fork of hk with Empire specific features.

Routing

Empire's routing layer is backed by internal ELBs. Any application that specifies a web process will get an internal ELB attached to its associated ECS Service. When a new version of the app is deployed, ECS manages spinning up the new versions of the process, waiting for old connections to drain, then killing the old release.

When a new internal ELB is created, an associated CNAME record will be created in Route53 under the internal TLD, which means you can use DNS for service discovery. If we deploy an app named feed then it will be available at http://feed within the ECS cluster.

Apps default to only being exposed internally, unless you add a custom domain to them. Adding a custom domain will create a new external ELB for the ECS service.

Deploying

Any tagged Docker image can be deployed to Empire as an app. Empire doesn't enforce how you tag your Docker images, but we recommend tagging the image with the git sha that it was built from, and deploying that. We have a tool for performing deployments called Tugboat that supports deploying Docker images to Empire.

When you deploy a Docker image to Empire, it will extract a Procfile from the WORKDIR. Like Heroku, you can specify different process types that compose your service (e.g. web and worker), and scale them individually. Each process type in the Procfile maps directly to an ECS Service.

Caveats

Because docker run does not exec commands within a shell, commands specified within the Procfile will also not be exec'd within a shell. This means that you cannot specify environment variables in the Procfile. The following is not valid:

web: acme-inc server -port=$PORT

If you need to specify environment variables as part of the command, we recommend splitting out your Procfile commands into small bash shims instead:

web: ./bin/web
#!/bin/bash

set -e

exec acme-inc server -port=$PORT

Tests

Unit tests live alongside each go file as _test.go.

There is also a tests directory that contains integration and functional tests that tests the system using the heroku-go client and the emp command.

To get started, run:

$ export GO15VENDOREXPERIMENT=1
$ make bootstrap

The bootstrap command assumes you have a running postgres server. It will create a database called empire using the postgres client connection defaults.

To run the tests:

$ go test ./...

Development

If you want to contribute to Empire, you may end up wanting to run a local instance against an ECS cluster. Doing this is relatively easy:

  1. Ensure that you have the AWS CLI installed and configured.

  2. Ensure that you accepted the terms and conditions for the official ECS AMI:

    https://aws.amazon.com/marketplace/ordering?productId=4ce33fd9-63ff-4f35-8d3a-939b641f1931&ref_=dtl_psb_continue&region=us-east-1

    Also check that the offical ECS AMI ID for US East matches with the one in cloudformation.json: https://github.com/remind101/empire/blob/master/docs/cloudformation.json#L20

  3. Run docker-machine and export the environment variables so Empire can connect:

    $ docker-machine start default
    $ eval "$(docker-machine env default)"
    
  4. Run the bootstrap script, which will create a cloudformation stack, ecs cluster and populate a .env file:

    $ DEMOMODE=0 ./bin/bootstrap
    
  5. Run Empire with docker-compose:

    $ docker-compose up
    

    NOTE: You might need to run this twice the first time you start it up, to give the postgres container time to initialize.

  6. Install the emp CLI.

Empire will be available at http://$(docker-machine ip default):8080 and you can point the CLI there.

$ export EMPIRE_API_URL=http://$(docker-machine ip default):8080
$ emp deploy remind101/acme-inc
Vendoring

Empire follows Go's convention of vendoring third party dependencies. We use the Go 1.5+ vendor expirement, and manage the ./vendor/ directory via govendor.

When you add a new dependency, be sure to vendor it with govendor:

$ govendor add <package>
Releasing

Perform the following steps when releasing a new version:

  1. Create a new branch release-VERSION.
  2. Bump the version number with make bump (this will add a commit to the branch).
  3. Change HEAD -> VERSION in [CHANGELOG.md][./CHANGELOG.md]
  4. Open a PR to review.
  5. Once merged into master, wait for the Conveyor build to complete.
  6. Finally, tag the commit with the version as v<VERSION>. This will trigger CircleCI to:
    • Tag the image in Docker Hub with the version.
    • Build Linux and OS X versions of the CLI and Daemon.
    • Create a new GitHub Release and upload the artifacts.
  7. Finally, update the new GitHub Release to be human readable.

Community

We have a google group, empire-dev, where you can ask questions and engage with the Empire community.

Documentation

Index

Constants

View Source
const (
	ExposePrivate = "private"
	ExposePublic  = "public"
)
View Source
const (
	// WebPort is the default PORT to set on web processes.
	WebPort = 8080

	// WebProcessType is the process type we assume are web server processes.
	WebProcessType = "web"
)
View Source
const Version = "0.10.0"

Variables

View Source
var (
	ErrDomainInUse        = errors.New("Domain currently in use by another app.")
	ErrDomainAlreadyAdded = errors.New("Domain already added to this app.")
	ErrDomainNotFound     = errors.New("Domain could not be found.")
)
View Source
var (
	// DefaultOptions is a default Options instance that can be passed when
	// intializing a new Empire.
	DefaultOptions = Options{}

	// DefaultReporter is the default reporter.Reporter to use.
	DefaultReporter = reporter.NewLogReporter()
)
View Source
var (
	Constraints1X = Constraints{constraints.CPUShare(256), constraints.Memory(512 * MB)}
	Constraints2X = Constraints{constraints.CPUShare(512), constraints.Memory(1 * GB)}
	ConstraintsPX = Constraints{constraints.CPUShare(1024), constraints.Memory(6 * GB)}

	// NamedConstraints maps a heroku dynos size to a Constraints.
	NamedConstraints = map[string]Constraints{
		"1X": Constraints1X,
		"2X": Constraints2X,
		"PX": ConstraintsPX,
	}

	// DefaultConstraints defaults to 1X process size.
	DefaultConstraints = Constraints1X
)
View Source
var All = ScopeFunc(func(db *gorm.DB) *gorm.DB {
	return db
})

All returns a scope that simply returns the db.

View Source
var DefaultQuantities = ProcessQuantityMap{
	"web": 1,
}

DefaultQuantities maps a process type to the default number of instances to run.

View Source
var (
	// ErrInvalidName is used to indicate that the app name is not valid.
	ErrInvalidName = &ValidationError{
		errors.New("An app name must be alphanumeric and dashes only, 3-30 chars in length."),
	}
)
View Source
var ErrNoPorts = errors.New("no ports avaiable")
View Source
var ErrNoReleases = errors.New("no releases")
View Source
var NamePattern = regexp.MustCompile(`^[a-z][a-z0-9-]{2,30}$`)

NamePattern is a regex pattern that app names must conform to.

View Source
var NullEventStream = EventStreamFunc(func(event Event) error {
	return nil
})

NullEventStream an events service that does nothing.

Functions

func AppID

func AppID(id string) func(*gorm.DB) *gorm.DB

AppID returns a scope to find an app by id.

func AppNameFromRepo

func AppNameFromRepo(repo string) string

AppNameFromRepo generates a name from a Repo

remind101/r101-api => r101-api

func SignToken

func SignToken(secret []byte, token *AccessToken) (string, error)

SignToken jwt signs the token and adds the signature to the Token field.

Types

type AccessToken

type AccessToken struct {
	Token string
	User  *User
}

AccessToken represents a token that allow access to the api.

func ParseToken

func ParseToken(secret []byte, token string) (*AccessToken, error)

ParseToken parses a string token, verifies it, and returns an AccessToken instance.

type App

type App struct {
	ID string

	Name string

	Repo *string

	// Valid values are empire.ExposePrivate and empire.ExposePublic.
	Exposure string

	// The name of an SSL cert for the web process of this app.
	Cert string

	CreatedAt *time.Time
}

App represents an app.

func (*App) BeforeCreate

func (a *App) BeforeCreate() error

func (*App) IsValid

func (a *App) IsValid() error

IsValid returns an error if the app isn't valid.

type AppsQuery

type AppsQuery struct {
	// If provided, an App ID to find.
	ID *string

	// If provided, finds apps matching the given name.
	Name *string

	// If provided, finds apps with the given repo attached.
	Repo *string
}

AppsQuery is a Scope implementation for common things to filter releases by.

func (AppsQuery) Scope

func (q AppsQuery) Scope(db *gorm.DB) *gorm.DB

Scope implements the Scope interface.

type AsyncEventStream added in v0.10.0

type AsyncEventStream struct {
	EventStream
	// contains filtered or unexported fields
}

AsyncEventStream wraps an EventStream to publish events asynchronously in a goroutine.

func AsyncEvents added in v0.10.0

func AsyncEvents(e EventStream) *AsyncEventStream

AsyncEvents returns a new AsyncEventStream that will buffer upto 100 events before applying backpressure.

func (*AsyncEventStream) PublishEvent added in v0.10.0

func (e *AsyncEventStream) PublishEvent(event Event) error

type Command

type Command string

Command represents the actual shell command that gets executed for a given ProcessType.

func (*Command) Scan

func (c *Command) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (Command) Value

func (c Command) Value() (driver.Value, error)

Value implements the driver.Value interface.

type CommandMap

type CommandMap map[ProcessType]Command

CommandMap maps a process ProcessType to a Command.

func (*CommandMap) Scan

func (cm *CommandMap) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (CommandMap) Value

func (cm CommandMap) Value() (driver.Value, error)

Value implements the driver.Value interface.

type ComposedScope

type ComposedScope []Scope

ComposedScope is an implementation of the Scope interface that chains the scopes together.

func (ComposedScope) Scope

func (s ComposedScope) Scope(db *gorm.DB) *gorm.DB

Scope implements the Scope interface.

type Config

type Config struct {
	ID   string
	Vars Vars

	AppID string
	App   *App
}

Config represents a collection of environment variables.

func NewConfig

func NewConfig(old *Config, vars Vars) *Config

NewConfig initializes a new config based on the old config, with the new variables provided.

type ConfigsQuery

type ConfigsQuery struct {
	// If provided, returns finds the config with the given id.
	ID *string

	// If provided, filters configs for the given app.
	App *App
}

ConfigsQuery is a Scope implementation for common things to filter releases by.

func (ConfigsQuery) Scope

func (q ConfigsQuery) Scope(db *gorm.DB) *gorm.DB

Scope implements the Scope interface.

type Constraints

type Constraints constraints.Constraints

Constraints aliases constraints.Constraints to implement the sql.Scanner interface.

func (Constraints) String

func (c Constraints) String() string

func (*Constraints) UnmarshalJSON

func (c *Constraints) UnmarshalJSON(b []byte) error

type CreateEvent added in v0.10.0

type CreateEvent struct {
	User string
	Name string
}

CreateEvent is triggered when a user creates a new application.

func (CreateEvent) Event added in v0.10.0

func (e CreateEvent) Event() string

func (CreateEvent) String added in v0.10.0

func (e CreateEvent) String() string

type CreateOpts added in v0.10.0

type CreateOpts struct {
	// User performing the action.
	User *User

	// Name of the application.
	Name string
}

CreateOpts are options that are provided when creating a new application.

func (CreateOpts) Event added in v0.10.0

func (opts CreateOpts) Event() CreateEvent

type DB added in v0.10.0

type DB struct {
	*gorm.DB
	// contains filtered or unexported fields
}

DB wraps a gorm.DB and provides the datastore layer for Empire.

func OpenDB added in v0.10.0

func OpenDB(uri string) (*DB, error)

OpenDB returns a new gorm.DB instance.

func (*DB) Debug added in v0.10.0

func (db *DB) Debug()

Debug puts the db in debug mode, which logs all queries.

func (*DB) IsHealthy added in v0.10.0

func (db *DB) IsHealthy() bool

IsHealthy checks that we can connect to the database.

func (*DB) MigrateUp added in v0.10.0

func (db *DB) MigrateUp(path string) ([]error, bool)

MigrateUp migrates the database to the latest version of the schema.

func (*DB) Reset added in v0.10.0

func (db *DB) Reset() error

Reset resets the database to a pristine state.

type DeployEvent added in v0.10.0

type DeployEvent struct {
	User  string
	App   string
	Image string
}

DeployEvent is triggered when a user deploys a new image to an app.

func (DeployEvent) Event added in v0.10.0

func (e DeployEvent) Event() string

func (DeployEvent) String added in v0.10.0

func (e DeployEvent) String() string

type DeploymentsCreateOpts

type DeploymentsCreateOpts struct {
	// User the user that is triggering the deployment.
	User *User

	// App is the app that is being deployed to.
	App *App

	// Image is the image that's being deployed.
	Image image.Image

	// Output is an io.Writer where deployment output and events will be
	// streamed in jsonmessage format.
	Output io.Writer
}

DeploymentsCreateOpts represents options that can be passed when deploying to an application.

func (DeploymentsCreateOpts) Event added in v0.10.0

func (opts DeploymentsCreateOpts) Event() DeployEvent

type DestroyEvent added in v0.10.0

type DestroyEvent struct {
	User string
	App  string
}

DestroyEvent is triggered when a user destroys an application.

func (DestroyEvent) Event added in v0.10.0

func (e DestroyEvent) Event() string

func (DestroyEvent) String added in v0.10.0

func (e DestroyEvent) String() string

type DestroyOpts added in v0.10.0

type DestroyOpts struct {
	// User performing the action.
	User *User

	// The associated app.
	App *App
}

DestroyOpts are options provided when destroying an application.

func (DestroyOpts) Event added in v0.10.0

func (opts DestroyOpts) Event() DestroyEvent

type Domain

type Domain struct {
	ID        string
	Hostname  string
	CreatedAt *time.Time

	AppID string
	App   *App
}

func (*Domain) BeforeCreate

func (d *Domain) BeforeCreate() error

type DomainsQuery

type DomainsQuery struct {
	// If provided, finds domains matching the given hostname.
	Hostname *string

	// If provided, filters domains belonging to the given app.
	App *App
}

DomainsQuery is a Scope implementation for common things to filter releases by.

func (DomainsQuery) Scope

func (q DomainsQuery) Scope(db *gorm.DB) *gorm.DB

Scope implements the Scope interface.

type Empire

type Empire struct {
	// Reporter is an reporter.Reporter that will be used to report errors to
	// an external system.
	reporter.Reporter

	// Logger is a log15 logger that will be used for logging.
	Logger log15.Logger

	DB *DB

	// Scheduler is the backend scheduler used to run applications.
	Scheduler scheduler.Scheduler

	// LogsStreamer is the backend used to stream application logs.
	LogsStreamer LogsStreamer

	// ExtractProcfile is called during deployments to extract the Procfile
	// from the newly deployed image.
	ExtractProcfile ProcfileExtractor

	// EventStream service for publishing Empire events.
	EventStream
	// contains filtered or unexported fields
}

Empire is a context object that contains a collection of services.

func New

func New(db *DB, options Options) *Empire

New returns a new Empire instance.

func (*Empire) AccessTokensCreate

func (e *Empire) AccessTokensCreate(accessToken *AccessToken) (*AccessToken, error)

AccessTokensCreate creates a new AccessToken.

func (*Empire) AccessTokensFind

func (e *Empire) AccessTokensFind(token string) (*AccessToken, error)

AccessTokensFind finds an access token.

func (*Empire) Apps

func (e *Empire) Apps(q AppsQuery) ([]*App, error)

Apps returns all Apps.

func (*Empire) AppsFind added in v0.10.0

func (e *Empire) AppsFind(q AppsQuery) (*App, error)

AppsFind finds the first app matching the query.

func (*Empire) CertsAttach added in v0.10.0

func (e *Empire) CertsAttach(ctx context.Context, app *App, cert string) error

CertsAttach attaches an SSL certificate to the app.

func (*Empire) Config added in v0.10.0

func (e *Empire) Config(app *App) (*Config, error)

Config returns the current Config for a given app.

func (*Empire) Create added in v0.10.0

func (e *Empire) Create(ctx context.Context, opts CreateOpts) (*App, error)

Create creates a new app.

func (*Empire) Deploy

func (e *Empire) Deploy(ctx context.Context, opts DeploymentsCreateOpts) (*Release, error)

Deploy deploys an image and streams the output to w.

func (*Empire) Destroy added in v0.10.0

func (e *Empire) Destroy(ctx context.Context, opts DestroyOpts) error

Destroy destroys an app.

func (*Empire) Domains

func (e *Empire) Domains(q DomainsQuery) ([]*Domain, error)

Domains returns all domains matching the query.

func (*Empire) DomainsCreate

func (e *Empire) DomainsCreate(ctx context.Context, domain *Domain) (*Domain, error)

DomainsCreate adds a new Domain for an App.

func (*Empire) DomainsDestroy

func (e *Empire) DomainsDestroy(ctx context.Context, domain *Domain) error

DomainsDestroy removes a Domain for an App.

func (*Empire) DomainsFind added in v0.10.0

func (e *Empire) DomainsFind(q DomainsQuery) (*Domain, error)

DomainsFind returns the first domain matching the query.

func (*Empire) IsHealthy

func (e *Empire) IsHealthy() bool

IsHealthy returns true if Empire is healthy, which means it can connect to the services it depends on.

func (*Empire) Releases

func (e *Empire) Releases(q ReleasesQuery) ([]*Release, error)

Releases returns all Releases for a given App.

func (*Empire) ReleasesFind added in v0.10.0

func (e *Empire) ReleasesFind(q ReleasesQuery) (*Release, error)

ReleasesFind returns the first releases for a given App.

func (*Empire) Reset

func (e *Empire) Reset() error

Reset resets empire.

func (*Empire) Restart added in v0.10.0

func (e *Empire) Restart(ctx context.Context, opts RestartOpts) error

Restart restarts processes matching the given prefix for the given Release. If the prefix is empty, it will match all processes for the release.

func (*Empire) Rollback added in v0.10.0

func (e *Empire) Rollback(ctx context.Context, opts RollbackOpts) (*Release, error)

Rollback rolls an app back to a specific release version. Returns a new release.

func (*Empire) Run added in v0.10.0

func (e *Empire) Run(ctx context.Context, opts RunOpts) error

Run runs a one-off process for a given App and command.

func (*Empire) Scale added in v0.10.0

func (e *Empire) Scale(ctx context.Context, opts ScaleOpts) (*Process, error)

Scale scales an apps process.

func (*Empire) Set added in v0.10.0

func (e *Empire) Set(ctx context.Context, opts SetOpts) (*Config, error)

Set applies the new config vars to the apps current Config, returning the new Config. If the app has a running release, a new release will be created and run.

func (*Empire) StreamLogs added in v0.9.2

func (e *Empire) StreamLogs(app *App, w io.Writer) error

Streamlogs streams logs from an app.

func (*Empire) Tasks added in v0.10.0

func (e *Empire) Tasks(ctx context.Context, app *App) ([]*Task, error)

Tasks returns the Tasks for the given app.

type Event added in v0.10.0

type Event interface {
	// Returns the name of the event.
	Event() string

	// Returns a human readable string about the event.
	String() string
}

Event represents an event triggered within Empire.

type EventStream added in v0.10.0

type EventStream interface {
	PublishEvent(Event) error
}

EventStream is an interface for publishing events that happen within Empire.

type EventStreamFunc added in v0.10.0

type EventStreamFunc func(Event) error

EventStreamFunc is a function that implements the Events interface.

func (EventStreamFunc) PublishEvent added in v0.10.0

func (fn EventStreamFunc) PublishEvent(event Event) error

type Formation

type Formation map[ProcessType]*Process

Formation maps a process ProcessType to a Process.

func NewFormation

func NewFormation(f Formation, cm CommandMap) Formation

NewFormation creates a new Formation based on an existing Formation and the available processes from a CommandMap.

func (Formation) Processes

func (f Formation) Processes() []*Process

Processes takes a Formation and returns a slice of the processes.

type KinesisLogsStreamer added in v0.10.0

type KinesisLogsStreamer struct{}

func NewKinesisLogsStreamer added in v0.10.0

func NewKinesisLogsStreamer() *KinesisLogsStreamer

func (*KinesisLogsStreamer) StreamLogs added in v0.10.0

func (s *KinesisLogsStreamer) StreamLogs(app *App, w io.Writer) error

type LogsStreamer added in v0.9.2

type LogsStreamer interface {
	StreamLogs(*App, io.Writer) error
}

type Options

type Options struct {
	Secret string
}

Options is provided to New to configure the Empire services.

type Port

type Port struct {
	ID    string
	AppID *string
	Port  int
}

type Process

type Process struct {
	ReleaseID string
	ID        string
	Type      ProcessType
	Quantity  int
	Command   Command
	Port      int `sql:"-"`
	Constraints
}

Process holds configuration information about a Process Type.

func NewProcess

func NewProcess(t ProcessType, cmd Command) *Process

NewProcess returns a new Process instance.

type ProcessQuantityMap

type ProcessQuantityMap map[ProcessType]int

ProcessQuantityMap represents a map of process types to quantities.

type ProcessType

type ProcessType string

ProcessType represents the type of a given process/command.

func (*ProcessType) Scan

func (p *ProcessType) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (ProcessType) Value

func (p ProcessType) Value() (driver.Value, error)

Value implements the driver.Value interface.

type ProcfileExtractor added in v0.10.0

type ProcfileExtractor func(context.Context, image.Image, io.Writer) (procfile.Procfile, error)

ProcfileExtractor is a function that can extract a Procfile from an image.

func PullAndExtract added in v0.10.0

func PullAndExtract(c *dockerutil.Client) ProcfileExtractor

PullAndExtract returns a ProcfileExtractor that will pull the image using the docker client, then attempt to extract the Procfile from the WORKDIR, or fallback to the CMD directive in the Procfile.

type Release

type Release struct {
	ID      string
	Version int

	AppID string
	App   *App

	ConfigID string
	Config   *Config

	SlugID string
	Slug   *Slug

	Processes []*Process

	Description string
	CreatedAt   *time.Time
}

Release is a combination of a Config and a Slug, which form a deployable release.

func (*Release) BeforeCreate

func (r *Release) BeforeCreate() error

BeforeCreate sets created_at before inserting.

func (*Release) Formation

func (r *Release) Formation() Formation

Formation creates a Formation object

func (*Release) Process added in v0.10.0

func (r *Release) Process(t ProcessType) *Process

Process return the Process with the given type.

type ReleasesQuery

type ReleasesQuery struct {
	// If provided, an app to filter by.
	App *App

	// If provided, a version to filter by.
	Version *int

	// If provided, uses the limit and sorting parameters specified in the range.
	Range headerutil.Range
}

ReleasesQuery is a Scope implementation for common things to filter releases by.

func (ReleasesQuery) DefaultRange

func (q ReleasesQuery) DefaultRange() headerutil.Range

DefaultRange returns the default headerutil.Range used if values aren't provided.

func (ReleasesQuery) Scope

func (q ReleasesQuery) Scope(db *gorm.DB) *gorm.DB

Scope implements the Scope interface.

type RestartEvent added in v0.10.0

type RestartEvent struct {
	User string
	App  string
	PID  string
}

RestartEvent is triggered when a user restarts an application.

func (RestartEvent) Event added in v0.10.0

func (e RestartEvent) Event() string

func (RestartEvent) String added in v0.10.0

func (e RestartEvent) String() string

type RestartOpts added in v0.10.0

type RestartOpts struct {
	// User performing the action.
	User *User

	// The associated app.
	App *App

	// If provided, a PID that will be killed. Generally used for killing
	// detached processes.
	PID string
}

RestartOpts are options provided when restarting an app.

func (RestartOpts) Event added in v0.10.0

func (opts RestartOpts) Event() RestartEvent

type RollbackEvent added in v0.10.0

type RollbackEvent struct {
	User    string
	App     string
	Version int
}

RollbackEvent is triggered when a user rolls back to an old version.

func (RollbackEvent) Event added in v0.10.0

func (e RollbackEvent) Event() string

func (RollbackEvent) String added in v0.10.0

func (e RollbackEvent) String() string

type RollbackOpts added in v0.10.0

type RollbackOpts struct {
	// The user performing the action.
	User *User

	// The associated app.
	App *App

	// The release version to rollback to.
	Version int
}

RollbackOpts are options provided when rolling back to an old release.

func (RollbackOpts) Event added in v0.10.0

func (opts RollbackOpts) Event() RollbackEvent

type RunEvent added in v0.10.0

type RunEvent struct {
	User     string
	App      string
	Command  string
	Attached bool
}

RunEvent is triggered when a user starts a one off process.

func (RunEvent) Event added in v0.10.0

func (e RunEvent) Event() string

func (RunEvent) String added in v0.10.0

func (e RunEvent) String() string

type RunOpts added in v0.10.0

type RunOpts struct {
	// User performing this action.
	User *User

	// Related app.
	App *App

	// The command to run.
	Command string

	// If provided, input will be read from this.
	Input io.Reader

	// If provided, output will be written to this.
	Output io.Writer

	// Extra environment variables to set.
	Env map[string]string
}

RunOpts are options provided when running an attached/detached process.

func (RunOpts) Event added in v0.10.0

func (opts RunOpts) Event() RunEvent

type ScaleEvent added in v0.10.0

type ScaleEvent struct {
	User             string
	App              string
	Process          string
	Quantity         int
	PreviousQuantity int
}

ScaleEvent is triggered when a manual scaling event happens.

func (ScaleEvent) Event added in v0.10.0

func (e ScaleEvent) Event() string

func (ScaleEvent) String added in v0.10.0

func (e ScaleEvent) String() string

type ScaleOpts added in v0.10.0

type ScaleOpts struct {
	// User that's performing the action.
	User *User

	// The associated app.
	App *App

	// The process type to scale.
	Process ProcessType

	// The desired quantity of processes.
	Quantity int

	// If provided, new memory and CPU constraints for the process.
	Constraints *Constraints
}

ScaleOpts are options provided when scaling a process.

func (ScaleOpts) Event added in v0.10.0

func (opts ScaleOpts) Event() ScaleEvent

type Scope

type Scope interface {
	Scope(*gorm.DB) *gorm.DB
}

Scope is an interface that scopes a gorm.DB. Scopes are used in ThingsFirst and ThingsAll methods on the store for filtering/querying.

func FieldEquals

func FieldEquals(field string, v interface{}) Scope

FieldEquals returns a Scope that filters on a field.

func ForApp

func ForApp(app *App) Scope

ForApp returns a Scope that will filter items belonging the the given app.

func ID

func ID(id string) Scope

ID returns a Scope that will find the item by id.

func Limit

func Limit(limit int) Scope

Limit returns a Scope that limits the results.

func Order

func Order(order string) Scope

Order returns a Scope that orders the results.

func Preload

func Preload(associations ...string) Scope

Preload returns a Scope that preloads the associations.

func Range

func Range(r headerutil.Range) Scope

Range returns a Scope that limits and orders the results.

type ScopeFunc

type ScopeFunc func(*gorm.DB) *gorm.DB

ScopeFunc implements the Scope interface for functions.

func (ScopeFunc) Scope

func (f ScopeFunc) Scope(db *gorm.DB) *gorm.DB

Scope implements the Scope interface.

type SetEvent added in v0.10.0

type SetEvent struct {
	User    string
	App     string
	Changed []string
}

SetEvent is triggered when environment variables are changed on an application.

func (SetEvent) Event added in v0.10.0

func (e SetEvent) Event() string

func (SetEvent) String added in v0.10.0

func (e SetEvent) String() string

type SetOpts added in v0.10.0

type SetOpts struct {
	// User performing the action.
	User *User

	// The associated app.
	App *App

	// The new vars to merge into the old config.
	Vars Vars
}

SetOpts are options provided when setting new config vars on an app.

func (SetOpts) Event added in v0.10.0

func (opts SetOpts) Event() SetEvent

type Slug

type Slug struct {
	ID           string
	Image        image.Image
	ProcessTypes CommandMap
}

Slug represents a container image with the extracted ProcessType.

type Task added in v0.10.0

type Task struct {
	Name        string
	Type        string
	Command     string
	State       string
	UpdatedAt   time.Time
	Constraints Constraints
}

Task represents a running process.

type User

type User struct {
	Name        string `json:"name"`
	GitHubToken string `json:"-"`
}

User represents a user of Empire.

func (*User) GitHubClient

func (u *User) GitHubClient() *http.Client

GitHubClient returns an http.Client that will automatically add the GitHubToken to all requests.

type ValidationError

type ValidationError struct {
	Err error
}

ValidationError is returned when a model is not valid.

func (*ValidationError) Error

func (e *ValidationError) Error() string

type Variable

type Variable string

Variable represents the name of an environment variable.

type Vars

type Vars map[Variable]*string

Vars represents a variable -> value mapping.

func (*Vars) Scan

func (v *Vars) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (Vars) Value

func (v Vars) Value() (driver.Value, error)

Value implements the driver.Value interface.

Directories

Path Synopsis
cmd
emp
events
sns
Package sns provides an empire.EventStream implementation that publishes events to SNS.
Package sns provides an empire.EventStream implementation that publishes events to SNS.
pkg
arn
package arn is a Go package for parsing Amazon Resource Names.
package arn is a Go package for parsing Amazon Resource Names.
bytesize
package bytesize contains constants for easily switching between different byte sizes.
package bytesize contains constants for easily switching between different byte sizes.
constraints
package constraints contains methods for decoding a compact CPU and Memory constraints format.
package constraints contains methods for decoding a compact CPU and Memory constraints format.
ecsutil
Package ecsutil is a layer on top of Amazon ECS to provide an app aware ECS client.
Package ecsutil is a layer on top of Amazon ECS to provide an app aware ECS client.
heroku
Package heroku is a client interface to the Heroku API.
Package heroku is a client interface to the Heroku API.
image
Package image contains methods and helpers for parsing the docker image format.
Package image contains methods and helpers for parsing the docker image format.
lb
package lb provides an abstraction around creating load balancers.
package lb provides an abstraction around creating load balancers.
runner
package runner provides a simple interface for running docker containers.
package runner provides a simple interface for running docker containers.
stream
Package stream provides types that make it easier to perform streaming.
Package stream provides types that make it easier to perform streaming.
stream/http
Package http provides streaming implementations of various net/http types.
Package http provides streaming implementations of various net/http types.
Package scheduler provides the core interface that Empire uses when interacting with a cluster of machines to run tasks.
Package scheduler provides the core interface that Empire uses when interacting with a cluster of machines to run tasks.
cloudformation
Package cloudformation implements the Scheduler interface for ECS by using CloudFormation to provision and update resources.
Package cloudformation implements the Scheduler interface for ECS by using CloudFormation to provision and update resources.
docker
Package docker implements the Scheduler interface backed by the Docker API.
Package docker implements the Scheduler interface backed by the Docker API.
ecs
Pacakge ecs provides an implementation of the Scheduler interface that uses Amazon EC2 Container Service.
Pacakge ecs provides an implementation of the Scheduler interface that uses Amazon EC2 Container Service.
kubernetes
Package kubernetes implements the Scheduler interface backed by Kubernetes.
Package kubernetes implements the Scheduler interface backed by Kubernetes.
auth
Package auth contains types for authenticating and authorizing requests.
Package auth contains types for authenticating and authorizing requests.
auth/github
Package github provides auth.Authentication and auth.Authorizer implementations backed by GitHub users, orgs and teams.
Package github provides auth.Authentication and auth.Authorizer implementations backed by GitHub users, orgs and teams.

Jump to

Keyboard shortcuts

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