Documentation ¶
Index ¶
- Constants
- Variables
- func AppID(id string) func(*gorm.DB) *gorm.DB
- func AppNameFromRepo(repo string) string
- func SignToken(secret []byte, token *AccessToken) (string, error)
- type AccessToken
- type App
- type AppEvent
- type AppsQuery
- type AsyncEventStream
- type CMDExtractor
- type Command
- type ComposedScope
- type Config
- type ConfigsQuery
- type Constraints
- type CreateEvent
- type CreateOpts
- type DB
- type DeployEvent
- type DeploymentsCreateOpts
- type DestroyEvent
- type DestroyOpts
- type Domain
- type DomainsQuery
- type Empire
- func (e *Empire) AccessTokensCreate(accessToken *AccessToken) (*AccessToken, error)
- func (e *Empire) AccessTokensFind(token string) (*AccessToken, error)
- func (e *Empire) Apps(q AppsQuery) ([]*App, error)
- func (e *Empire) AppsFind(q AppsQuery) (*App, error)
- func (e *Empire) CertsAttach(ctx context.Context, app *App, cert string) error
- func (e *Empire) Config(app *App) (*Config, error)
- func (e *Empire) Create(ctx context.Context, opts CreateOpts) (*App, error)
- func (e *Empire) Deploy(ctx context.Context, opts DeploymentsCreateOpts) (*Release, error)
- func (e *Empire) Destroy(ctx context.Context, opts DestroyOpts) error
- func (e *Empire) Domains(q DomainsQuery) ([]*Domain, error)
- func (e *Empire) DomainsCreate(ctx context.Context, domain *Domain) (*Domain, error)
- func (e *Empire) DomainsDestroy(ctx context.Context, domain *Domain) error
- func (e *Empire) DomainsFind(q DomainsQuery) (*Domain, error)
- func (e *Empire) IsHealthy() bool
- func (e *Empire) ListScale(ctx context.Context, app *App) (Formation, error)
- func (e *Empire) Releases(q ReleasesQuery) ([]*Release, error)
- func (e *Empire) ReleasesFind(q ReleasesQuery) (*Release, error)
- func (e *Empire) Reset() error
- func (e *Empire) Restart(ctx context.Context, opts RestartOpts) error
- func (e *Empire) Rollback(ctx context.Context, opts RollbackOpts) (*Release, error)
- func (e *Empire) Run(ctx context.Context, opts RunOpts) error
- func (e *Empire) Scale(ctx context.Context, opts ScaleOpts) (*Process, error)
- func (e *Empire) Set(ctx context.Context, opts SetOpts) (*Config, error)
- func (e *Empire) StreamLogs(app *App, w io.Writer, duration time.Duration) error
- func (e *Empire) Tasks(ctx context.Context, app *App) ([]*Task, error)
- type Event
- type EventStream
- type EventStreamFunc
- type FileExtractor
- type Formation
- type KinesisLogsStreamer
- type LogsStreamer
- type MessageRequiredError
- type MultiEventStream
- type Options
- type Process
- type ProcfileError
- type ProcfileExtractor
- type ProcfileExtractorFunc
- type Release
- type ReleasesQuery
- type RestartEvent
- type RestartOpts
- type RollbackEvent
- type RollbackOpts
- type RunEvent
- type RunOpts
- type RunRecorder
- type ScaleEvent
- type ScaleOpts
- type Scope
- type ScopeFunc
- type SetEvent
- type SetOpts
- type Slug
- type Task
- type User
- type ValidationError
- type Variable
- type Vars
Constants ¶
const ( ExposePrivate = "private" ExposePublic = "public" )
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" )
const Version = "0.10.1"
Variables ¶
var ( Constraints1X = Constraints{constraints.CPUShare(256), constraints.Memory(512 * MB), constraints.Nproc(256)} Constraints2X = Constraints{constraints.CPUShare(512), constraints.Memory(1 * GB), constraints.Nproc(512)} ConstraintsPX = Constraints{constraints.CPUShare(1024), constraints.Memory(6 * GB), 0} // 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 )
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.") )
All returns a scope that simply returns the db.
var ( // DefaultOptions is a default Options instance that can be passed when // intializing a new Empire. DefaultOptions = Options{} )
var DefaultQuantities = map[string]int{
"web": 1,
}
DefaultQuantities maps a process type to the default number of instances to run.
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."), } )
var ErrNoReleases = errors.New("no releases")
var ErrUserName = errors.New("Name is required")
var Migrations = []migrate.Migration{ { ID: 1, Up: migrate.Queries([]string{ `CREATE EXTENSION IF NOT EXISTS hstore`, `CREATE EXTENSION IF NOT EXISTS "uuid-ossp"`, `CREATE TABLE apps ( id uuid NOT NULL DEFAULT uuid_generate_v4() primary key, name varchar(30) NOT NULL, github_repo text, docker_repo text, created_at timestamp without time zone default (now() at time zone 'utc') )`, `CREATE TABLE configs ( id uuid NOT NULL DEFAULT uuid_generate_v4() primary key, app_id uuid NOT NULL references apps(id) ON DELETE CASCADE, vars hstore, created_at timestamp without time zone default (now() at time zone 'utc') )`, `CREATE TABLE slugs ( id uuid NOT NULL DEFAULT uuid_generate_v4() primary key, image text NOT NULL, process_types hstore NOT NULL )`, `CREATE TABLE releases ( id uuid NOT NULL DEFAULT uuid_generate_v4() primary key, app_id uuid NOT NULL references apps(id) ON DELETE CASCADE, config_id uuid NOT NULL references configs(id) ON DELETE CASCADE, slug_id uuid NOT NULL references slugs(id) ON DELETE CASCADE, version int NOT NULL, description text, created_at timestamp without time zone default (now() at time zone 'utc') )`, `CREATE TABLE processes ( id uuid NOT NULL DEFAULT uuid_generate_v4() primary key, release_id uuid NOT NULL references releases(id) ON DELETE CASCADE, "type" text NOT NULL, quantity int NOT NULL, command text NOT NULL )`, `CREATE TABLE jobs ( id uuid NOT NULL DEFAULT uuid_generate_v4() primary key, app_id uuid NOT NULL references apps(id) ON DELETE CASCADE, release_version int NOT NULL, process_type text NOT NULL, instance int NOT NULL, environment hstore NOT NULL, image text NOT NULL, command text NOT NULL, updated_at timestamp without time zone default (now() at time zone 'utc') )`, `CREATE TABLE deployments ( id uuid NOT NULL DEFAULT uuid_generate_v4() primary key, app_id uuid NOT NULL references apps(id) ON DELETE CASCADE, release_id uuid references releases(id), image text NOT NULL, status text NOT NULL, error text, created_at timestamp without time zone default (now() at time zone 'utc'), finished_at timestamp without time zone )`, `CREATE UNIQUE INDEX index_apps_on_name ON apps USING btree (name)`, `CREATE UNIQUE INDEX index_apps_on_github_repo ON apps USING btree (github_repo)`, `CREATE UNIQUE INDEX index_apps_on_docker_repo ON apps USING btree (docker_repo)`, `CREATE UNIQUE INDEX index_processes_on_release_id_and_type ON processes USING btree (release_id, "type")`, `CREATE UNIQUE INDEX index_slugs_on_image ON slugs USING btree (image)`, `CREATE UNIQUE INDEX index_releases_on_app_id_and_version ON releases USING btree (app_id, version)`, `CREATE UNIQUE INDEX index_jobs_on_app_id_and_release_version_and_process_type_and_instance ON jobs (app_id, release_version, process_type, instance)`, `CREATE INDEX index_configs_on_created_at ON configs (created_at)`, }), Down: migrate.Queries([]string{ `DROP TABLE apps CASCADE`, `DROP TABLE configs CASCADE`, `DROP TABLE slugs CASCADE`, `DROP TABLE releases CASCADE`, `DROP TABLE processes CASCADE`, `DROP TABLE jobs CASCADE`, `DROP TABLE deployments CASCADE`, }), }, { ID: 2, Up: migrate.Queries([]string{ `CREATE TABLE domains ( id uuid NOT NULL DEFAULT uuid_generate_v4() primary key, app_id uuid NOT NULL references apps(id) ON DELETE CASCADE, hostname text NOT NULL, created_at timestamp without time zone default (now() at time zone 'utc') )`, `CREATE INDEX index_domains_on_app_id ON domains USING btree (app_id)`, `CREATE UNIQUE INDEX index_domains_on_hostname ON domains USING btree (hostname)`, }), Down: migrate.Queries([]string{ `DROP TABLE domains CASCADE`, }), }, { ID: 3, Up: migrate.Queries([]string{ `DROP TABLE jobs`, }), Down: migrate.Queries([]string{ `CREATE TABLE jobs ( id uuid NOT NULL DEFAULT uuid_generate_v4() primary key, app_id text NOT NULL references apps(name) ON DELETE CASCADE, release_version int NOT NULL, process_type text NOT NULL, instance int NOT NULL, environment hstore NOT NULL, image text NOT NULL, command text NOT NULL, updated_at timestamp without time zone default (now() at time zone 'utc') )`, }), }, { ID: 4, Up: migrate.Queries([]string{ `CREATE TABLE ports ( id uuid NOT NULL DEFAULT uuid_generate_v4() primary key, port integer, app_id uuid references apps(id) ON DELETE SET NULL )`, `-- Insert 1000 ports INSERT INTO ports (port) (SELECT generate_series(9000,10000))`, }), Down: migrate.Queries([]string{ `DROP TABLE ports CASCADE`, }), }, { ID: 5, Up: migrate.Queries([]string{ `ALTER TABLE apps DROP COLUMN docker_repo`, `ALTER TABLE apps DROP COLUMN github_repo`, `ALTER TABLE apps ADD COLUMN repo text`, `DROP TABLE deployments`, }), Down: migrate.Queries([]string{ `ALTER TABLE apps DROP COLUMN repo`, `ALTER TABLE apps ADD COLUMN docker_repo text`, `ALTER TABLE apps ADD COLUMN github_repo text`, `CREATE TABLE deployments ( id uuid NOT NULL DEFAULT uuid_generate_v4() primary key, app_id text NOT NULL references apps(name) ON DELETE CASCADE, release_id uuid references releases(id), image text NOT NULL, status text NOT NULL, error text, created_at timestamp without time zone default (now() at time zone 'utc'), finished_at timestamp without time zone )`, }), }, { ID: 6, Up: migrate.Queries([]string{ `DROP INDEX index_slugs_on_image`, }), Down: migrate.Queries([]string{ `CREATE UNIQUE INDEX index_slugs_on_image ON slugs USING btree (image)`, }), }, { ID: 7, Up: migrate.Queries([]string{ `-- Values: private, public ALTER TABLE apps ADD COLUMN exposure TEXT NOT NULL default 'private'`, }), Down: migrate.Queries([]string{ `ALTER TABLE apps DROP COLUMN exposure`, }), }, { ID: 8, Up: migrate.Queries([]string{ `CREATE TABLE certificates ( id uuid NOT NULL DEFAULT uuid_generate_v4() primary key, app_id uuid NOT NULL references apps(id) ON DELETE CASCADE, name text, certificate_chain text, created_at timestamp without time zone default (now() at time zone 'utc'), updated_at timestamp without time zone default (now() at time zone 'utc') )`, `CREATE UNIQUE INDEX index_certificates_on_app_id ON certificates USING btree (app_id)`, }), Down: migrate.Queries([]string{ `DROP TABLE certificates CASCADE`, }), }, { ID: 9, Up: migrate.Queries([]string{ `ALTER TABLE processes ADD COLUMN cpu_share int`, `ALTER TABLE processes ADD COLUMN memory int`, `UPDATE processes SET cpu_share = 256, memory = 1073741824`, }), Down: migrate.Queries([]string{ `ALTER TABLE processes DROP COLUMN cpu_share`, `ALTER TABLE processes DROP COLUMN memory`, }), }, { ID: 10, Up: migrate.Queries([]string{ `ALTER TABLE processes ALTER COLUMN memory TYPE bigint`, }), Down: migrate.Queries([]string{ `ALTER TABLE processes ALTER COLUMN memory TYPE integer`, }), }, { ID: 11, Up: migrate.Queries([]string{ `ALTER TABLE apps ADD COLUMN cert text`, `UPDATE apps SET cert = (select name from certificates where certificates.app_id = apps.id)`, }), Down: migrate.Queries([]string{ `ALTER TABLE apps DROP COLUMN cert`, }), }, { ID: 12, Up: migrate.Queries([]string{ `ALTER TABLE processes ADD COLUMN nproc bigint`, `UPDATE processes SET nproc = 0`, }), Down: migrate.Queries([]string{ `ALTER TABLE processes DROP COLUMN nproc`, }), }, { ID: 13, Up: migrate.Queries([]string{ `ALTER TABLE ports ADD COLUMN taken text`, `UPDATE ports SET taken = 't' FROM (SELECT port FROM ports WHERE app_id is not NULL) as used_ports WHERE ports.port = used_ports.port`, }), Down: migrate.Queries([]string{ `ALTER TABLE ports DROP column taken`, }), }, { ID: 14, Up: func(tx *sql.Tx) error { _, err := tx.Exec(`ALTER TABLE slugs ADD COLUMN process_types_json json`) if err != nil { return err } _, err = tx.Exec(`ALTER TABLE processes ADD COLUMN command_json json`) if err != nil { return err } rows, err := tx.Query(`SELECT id, process_types FROM slugs`) if err != nil { return err } slugs := make(map[string]map[string]Command) for rows.Next() { var id string var ptypes hstore.Hstore if err := rows.Scan(&id, &ptypes); err != nil { return err } m := make(map[string]Command) for k, v := range ptypes.Map { command, err := ParseCommand(v.String) if err != nil { return err } m[k] = command } slugs[id] = m } if err := rows.Err(); err != nil { return err } rows.Close() for id, ptypes := range slugs { raw, err := json.Marshal(ptypes) if err != nil { return err } _, err = tx.Exec(`UPDATE slugs SET process_types_json = $1 WHERE id = $2`, raw, id) if err != nil { return err } } _, err = tx.Exec(`ALTER TABLE slugs DROP COLUMN process_types`) if err != nil { return err } _, err = tx.Exec(`ALTER TABLE slugs RENAME COLUMN process_types_json to process_types`) if err != nil { return err } _, err = tx.Exec(`ALTER TABLE slugs ALTER COLUMN process_types SET NOT NULL`) if err != nil { return err } rows, err = tx.Query(`SELECT id, command FROM processes`) if err != nil { return err } commands := make(map[string]string) for rows.Next() { var id, command string if err := rows.Scan(&id, &command); err != nil { return err } commands[id] = command } if err := rows.Err(); err != nil { return err } rows.Close() for id, command := range commands { cmd, err := ParseCommand(command) if err != nil { return err } query := `UPDATE processes SET command_json = $1 WHERE id = $2` _, err = tx.Exec(query, cmd, id) if err != nil { return err } } _, err = tx.Exec(`ALTER TABLE processes DROP COLUMN command`) if err != nil { return err } _, err = tx.Exec(`ALTER TABLE processes RENAME COLUMN command_json TO command`) if err != nil { return err } _, err = tx.Exec(`ALTER TABLE processes ALTER COLUMN command SET NOT NULL`) return err }, Down: migrate.Queries([]string{ `ALTER TABLE processes DROP COLUMN command`, `ALTER TABLE processes ADD COLUMN command text not null`, `ALTER TABLE slugs DROP COLUMN process_types`, `ALTER TABLE slugs ADD COLUMN process_types hstore not null`, }), }, { ID: 15, Up: func(tx *sql.Tx) error { _, err := tx.Exec(`ALTER TABLE slugs ADD COLUMN procfile bytea`) if err != nil { return err } _, err = tx.Exec(`ALTER TABLE releases ADD COLUMN formation json`) if err != nil { return err } rows, err := tx.Query(`SELECT id, process_types FROM slugs`) if err != nil { return err } slugs := make(map[string]procfile.Procfile) for rows.Next() { var id string var ptypes []byte if err := rows.Scan(&id, &ptypes); err != nil { return err } m := make(map[string][]string) if err := json.Unmarshal(ptypes, &m); err != nil { return err } p := make(procfile.ExtendedProcfile) for name, command := range m { p[name] = procfile.Process{ Command: command, } } slugs[id] = p } if err := rows.Err(); err != nil { return err } rows.Close() for id, p := range slugs { raw, err := procfile.Marshal(p) if err != nil { return err } _, err = tx.Exec(`UPDATE slugs SET procfile = $1 WHERE id = $2`, raw, id) if err != nil { return err } } _, err = tx.Exec(`ALTER TABLE slugs DROP COLUMN process_types`) if err != nil { return err } _, err = tx.Exec(`ALTER TABLE slugs ALTER COLUMN procfile SET NOT NULL`) if err != nil { return err } rows, err = tx.Query(`SELECT release_id, id, type, quantity, command, memory, cpu_share, nproc FROM processes`) if err != nil { return err } formations := make(map[string]Formation) for rows.Next() { var release, id, ptype string var command Command var quantity, memory, cpu, nproc int if err := rows.Scan(&release, &id, &ptype, &quantity, &command, &memory, &cpu, &nproc); err != nil { return err } if formations[release] == nil { formations[release] = make(Formation) } f := formations[release] f[ptype] = Process{ Command: command, Quantity: quantity, Memory: constraints.Memory(memory), CPUShare: constraints.CPUShare(cpu), Nproc: constraints.Nproc(nproc), } } if err := rows.Err(); err != nil { return err } rows.Close() for id, f := range formations { _, err = tx.Exec(`UPDATE releases SET formation = $1 WHERE id = $2`, f, id) if err != nil { return err } } _, err = tx.Exec(`ALTER TABLE releases ALTER COLUMN formation SET NOT NULL`) if err != nil { return err } _, err = tx.Exec(`DROP TABLE processes`) return err }, Down: migrate.Queries([]string{ `ALTER TABLE releases DROP COLUMN formation`, `ALTER TABLE slugs DROP COLUMN procfile`, `ALTER TABLE slugs ADD COLUMN process_types hstore not null`, `CREATE TABLE processes ( id uuid NOT NULL DEFAULT uuid_generate_v4() primary key, release_id uuid NOT NULL references releases(id) ON DELETE CASCADE, "type" text NOT NULL, quantity int NOT NULL, command text NOT NULL, cpu_share int, memory bigint, nproc bigint )`, `CREATE UNIQUE INDEX index_processes_on_release_id_and_type ON processes USING btree (release_id, "type")`, }), }, { ID: 16, Up: migrate.Queries([]string{ `CREATE TABLE stacks ( app_id text NOT NULL, stack_name text NOT NULL )`, `CREATE UNIQUE INDEX index_stacks_on_app_id ON stacks USING btree (app_id)`, `CREATE UNIQUE INDEX index_stacks_on_stack_name ON stacks USING btree (stack_name)`, }), Down: migrate.Queries([]string{ `DROP TABLE stacks`, }), }, { ID: 17, Up: migrate.Queries([]string{ `CREATE TABLE scheduler_migration (app_id text NOT NULL, backend text NOT NULL)`, `INSERT INTO scheduler_migration (app_id, backend) SELECT id, 'ecs' FROM apps`, }), Down: migrate.Queries([]string{ `DROP TABLE scheduler_migration`, }), }, }
var NamePattern = regexp.MustCompile(`^[a-z][a-z0-9-]{2,30}$`)
NamePattern is a regex pattern that app names must conform to.
var NullEventStream = EventStreamFunc(func(event Event) error { return nil })
NullEventStream an events service that does nothing.
var (
// ProcfileName is the name of the Procfile file.
ProcfileName = "Procfile"
)
Functions ¶
Types ¶
type AccessToken ¶
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.
func (*AccessToken) IsValid ¶ added in v0.10.1
func (t *AccessToken) IsValid() error
IsValid returns nil if the AccessToken is valid.
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 ¶
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.
type AsyncEventStream ¶ added in v0.10.0
type AsyncEventStream struct { EventStream // contains filtered or unexported fields }
AsyncEventStream wraps an array of EventStreams 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 CMDExtractor ¶ added in v0.10.1
type CMDExtractor struct {
// contains filtered or unexported fields
}
CommandExtractor is an Extractor implementation that returns a Procfile based on the CMD directive in the Dockerfile. It makes the assumption that the cmd is a "web" process.
func NewCMDExtractor ¶ added in v0.10.1
func NewCMDExtractor(c *docker.Client) *CMDExtractor
type Command ¶
type Command []string
Command represents the actual shell command that gets executed for a given ProcessType.
func MustParseCommand ¶ added in v0.10.1
MustParseCommand parses the string into a Command, panicing if there's an error. This method should only be used in tests for convenience.
func ParseCommand ¶ added in v0.10.1
ParseCommand parses a string into a Command, taking quotes and other shell words into account.
type ComposedScope ¶
type ComposedScope []Scope
ComposedScope is an implementation of the Scope interface that chains the scopes together.
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.
type Constraints ¶
type Constraints constraints.Constraints
Constraints aliases empire.Constraints type to implement the json.Unmarshaller 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
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 // Commit message Message 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
func (CreateOpts) Validate ¶ added in v0.10.1
func (opts CreateOpts) Validate(e *Empire) error
type DB ¶ added in v0.10.0
DB wraps a gorm.DB and provides the datastore layer for Empire.
func (*DB) Debug ¶ added in v0.10.0
func (db *DB) Debug()
Debug puts the db in debug mode, which logs all queries.
type DeployEvent ¶ added in v0.10.0
type DeployEvent struct { User string App string Image string Environment string Release int Message string // contains filtered or unexported fields }
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) GetApp ¶ added in v0.10.1
func (e DeployEvent) GetApp() *App
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 // Environment is the environment where the image is being deployed Environment string // Output is an io.Writer where deployment output and events will be // streamed in jsonmessage format. Output io.Writer // Commit message Message string }
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
func (DeploymentsCreateOpts) Validate ¶ added in v0.10.1
func (opts DeploymentsCreateOpts) Validate(e *Empire) error
type DestroyEvent ¶ added in v0.10.0
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 // Commit message Message string }
DestroyOpts are options provided when destroying an application.
func (DestroyOpts) Event ¶ added in v0.10.0
func (opts DestroyOpts) Event() DestroyEvent
func (DestroyOpts) Validate ¶ added in v0.10.1
func (opts DestroyOpts) Validate(e *Empire) error
type Domain ¶
func (*Domain) BeforeCreate ¶
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.
type Empire ¶
type Empire struct { 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 // ProcfileExtractor is called during deployments to extract the // Formation from the Procfile in the newly deployed image. ProcfileExtractor ProcfileExtractor // Environment represents the environment this Empire server is responsible for Environment string // EventStream service for publishing Empire events. EventStream // RunRecorder is used to record the logs from interactive runs. RunRecorder RunRecorder // MessagesRequired is a boolean used to determine if messages should be required for events. MessagesRequired bool // contains filtered or unexported fields }
Empire is a context object that contains a collection of services.
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) CertsAttach ¶ added in v0.10.0
CertsAttach attaches an SSL certificate to the app.
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 ¶
DomainsCreate adds a new Domain for an App.
func (*Empire) DomainsDestroy ¶
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 ¶
IsHealthy returns true if Empire is healthy, which means it can connect to the services it depends on.
func (*Empire) ListScale ¶ added in v0.10.1
ListScale lists the current scale settings for a given App
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) 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
Rollback rolls an app back to a specific release version. Returns a new release.
func (*Empire) Set ¶ added in v0.10.0
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
Streamlogs streams logs from an 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
EventStream is an interface for publishing events that happen within Empire.
type EventStreamFunc ¶ added in v0.10.0
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 FileExtractor ¶ added in v0.10.1
type FileExtractor struct {
// contains filtered or unexported fields
}
FileExtractor is an implementation of the Extractor interface that extracts the Procfile from the images WORKDIR.
func NewFileExtractor ¶ added in v0.10.1
func NewFileExtractor(c *docker.Client) *FileExtractor
type Formation ¶
Formation represents a collection of named processes and their configuration.
func (Formation) Merge ¶ added in v0.10.1
Merge merges in the existing quantity and constraints from the old Formation into this Formation.
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
type LogsStreamer ¶ added in v0.9.2
type MessageRequiredError ¶ added in v0.10.1
type MessageRequiredError struct{}
func (*MessageRequiredError) Error ¶ added in v0.10.1
func (e *MessageRequiredError) Error() string
type MultiEventStream ¶ added in v0.10.1
type MultiEventStream []EventStream
MultiEventStream is an EventStream implementation that publishes the event to multiple EventStreams, returning any errors after publishing to all streams.
func (MultiEventStream) PublishEvent ¶ added in v0.10.1
func (streams MultiEventStream) PublishEvent(e Event) error
type Options ¶
type Options struct {
Secret string
}
Options is provided to New to configure the Empire services.
type Process ¶
type Process struct { Command Command `json:"Command,omitempty"` Quantity int `json:"Quantity,omitempty"` Memory constraints.Memory `json:"Memory,omitempty"` Nproc constraints.Nproc `json:"Nproc,omitempty"` }
Process holds configuration information about a Process.
func (*Process) Constraints ¶ added in v0.10.1
func (p *Process) Constraints() Constraints
Constraints returns a constraints.Constraints from this Process definition.
func (*Process) SetConstraints ¶ added in v0.10.1
func (p *Process) SetConstraints(c Constraints)
SetConstraints sets the memory/cpu/nproc for this Process to the given constraints.
type ProcfileError ¶
type ProcfileError struct {
Err error
}
Example instance: Procfile doesn't exist
func (*ProcfileError) Error ¶
func (e *ProcfileError) Error() string
type ProcfileExtractor ¶ added in v0.10.0
type ProcfileExtractor interface {
Extract(context.Context, image.Image, io.Writer) ([]byte, error)
}
ProcfileExtractor represents something that can extract a Procfile from an image.
func MultiExtractor ¶ added in v0.10.1
func MultiExtractor(extractors ...ProcfileExtractor) ProcfileExtractor
MultiExtractor is an Extractor implementation that tries multiple Extractors in succession until one succeeds.
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 the Procfile, or fallback to the CMD directive in the Dockerfile.
type ProcfileExtractorFunc ¶ added in v0.10.1
type Release ¶
type Release struct { ID string Version int AppID string App *App ConfigID string Config *Config SlugID string Slug *Slug Formation Formation Description string CreatedAt *time.Time }
Release is a combination of a Config and a Slug, which form a deployable release.
func (*Release) BeforeCreate ¶
BeforeCreate sets created_at before inserting.
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.
type RestartEvent ¶ added in v0.10.0
type RestartEvent struct { User string App string PID string Message string // contains filtered or unexported fields }
RestartEvent is triggered when a user restarts an application.
func (RestartEvent) Event ¶ added in v0.10.0
func (e RestartEvent) Event() string
func (RestartEvent) GetApp ¶ added in v0.10.1
func (e RestartEvent) GetApp() *App
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 // Commit message Message string }
RestartOpts are options provided when restarting an app.
func (RestartOpts) Event ¶ added in v0.10.0
func (opts RestartOpts) Event() RestartEvent
func (RestartOpts) Validate ¶ added in v0.10.1
func (opts RestartOpts) Validate(e *Empire) error
type RollbackEvent ¶ added in v0.10.0
type RollbackEvent struct { User string App string Version int Message string // contains filtered or unexported fields }
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) GetApp ¶ added in v0.10.1
func (e RollbackEvent) GetApp() *App
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 // Commit message Message string }
RollbackOpts are options provided when rolling back to an old release.
func (RollbackOpts) Event ¶ added in v0.10.0
func (opts RollbackOpts) Event() RollbackEvent
func (RollbackOpts) Validate ¶ added in v0.10.1
func (opts RollbackOpts) Validate(e *Empire) error
type RunEvent ¶ added in v0.10.0
type RunEvent struct { User string App string Command Command URL string Attached bool Message string // contains filtered or unexported fields }
RunEvent is triggered when a user starts a one off process.
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 Command // Commit message Message 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 // Optional memory/cpu/nproc constraints. Constraints *Constraints }
RunOpts are options provided when running an attached/detached process.
type RunRecorder ¶ added in v0.10.1
RunRecorder is a function that returns an io.Writer that will be written to to record Stdout and Stdin of interactive runs.
func RecordTo ¶ added in v0.10.1
func RecordTo(w io.Writer) RunRecorder
RecordTo returns a RunRecorder that writes the log record to the io.Writer
func RecordToCloudWatch ¶ added in v0.10.1
func RecordToCloudWatch(group string, config client.ConfigProvider) RunRecorder
RecordToCloudWatch returns a RunRecorder that writes the log record to CloudWatch Logs.
type ScaleEvent ¶ added in v0.10.0
type ScaleEvent struct { User string App string Process string Quantity int PreviousQuantity int Constraints Constraints PreviousConstraints Constraints Message string // contains filtered or unexported fields }
ScaleEvent is triggered when a manual scaling event happens.
func (ScaleEvent) Event ¶ added in v0.10.0
func (e ScaleEvent) Event() string
func (ScaleEvent) GetApp ¶ added in v0.10.1
func (e ScaleEvent) GetApp() *App
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 to scale. Process string // The desired quantity of processes. Quantity int // If provided, new memory and CPU constraints for the process. Constraints *Constraints // Commit message Message string }
ScaleOpts are options provided when scaling a process.
func (ScaleOpts) Event ¶ added in v0.10.0
func (opts ScaleOpts) Event() ScaleEvent
type Scope ¶
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 ¶
FieldEquals returns a Scope that filters on a field.
func Range ¶
func Range(r headerutil.Range) Scope
Range returns a Scope that limits and orders the results.
type SetEvent ¶ added in v0.10.0
type SetEvent struct { User string App string Changed []string Message string // contains filtered or unexported fields }
SetEvent is triggered when environment variables are changed on an application.
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 // Commit message Message string }
SetOpts are options provided when setting new config vars on an app.
type Task ¶ added in v0.10.0
type Task struct { Name string Type string Command Command State string UpdatedAt time.Time Constraints Constraints }
Task represents a running process.
type ValidationError ¶
type ValidationError struct {
Err error
}
ValidationError is returned when a model is not valid.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
events
|
|
app
Package app provides an empire.EventStream implementation that publishs events to the app's kinesis stream if available.
|
Package app provides an empire.EventStream implementation that publishs events to the app's kinesis stream if available. |
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. |
stdout
Package stdout provides an empire.EventStream implementation that publishes events to stdout.
|
Package stdout provides an empire.EventStream implementation that publishes events to stdout. |
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. |
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. |
ecs/lb
package lb provides an abstraction around creating load balancers.
|
package lb provides an abstraction around creating load balancers. |
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. |