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 AppsQuery
- type AsyncEventStream
- type Command
- type CommandMap
- 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) 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) error
- func (e *Empire) Tasks(ctx context.Context, app *App) ([]*Task, error)
- type Event
- type EventStream
- type EventStreamFunc
- type Formation
- type KinesisLogsStreamer
- type LogsStreamer
- type Options
- type Port
- type Process
- type ProcessQuantityMap
- type ProcessType
- type ProcfileExtractor
- type Release
- type ReleasesQuery
- type RestartEvent
- type RestartOpts
- type RollbackEvent
- type RollbackOpts
- type RunEvent
- type RunOpts
- 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.0"
Variables ¶
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.") )
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() )
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 )
All returns a scope that simply returns the db.
var DefaultQuantities = ProcessQuantityMap{
"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 ErrNoPorts = errors.New("no ports avaiable")
var ErrNoReleases = errors.New("no releases")
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.
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.
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 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.
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.
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 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
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
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
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
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 ¶
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 { // 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 (*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) 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 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.
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 Options ¶
type Options struct {
Secret string
}
Options is provided to New to configure the Empire services.
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.
type ProcfileExtractor ¶ added in v0.10.0
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 ¶
BeforeCreate sets created_at before inserting.
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.
type RestartEvent ¶ added in v0.10.0
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
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 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.
type ScaleEvent ¶ added in v0.10.0
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 ¶
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
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 }
SetOpts are options provided when setting new config vars on an app.
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 ¶
User represents a user of Empire.
func (*User) GitHubClient ¶
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
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
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. |